# HG changeset patch # User Bram Moolenaar # Date 1580329805 -3600 # Node ID d776967d0f0dac1304631ac3788574e70a01c7b2 # Parent 6db2a20db2c39f6bb330a303ca65646a260f78b9 patch 8.2.0173: build fails with old compiler Commit: https://github.com/vim/vim/commit/0ff6aad393c4130818fb4f49137380f78d7cc882 Author: Bram Moolenaar Date: Wed Jan 29 21:27:21 2020 +0100 patch 8.2.0173: build fails with old compiler Problem: Build fails with old compiler. Solution: Do not use anonymous unions. (John Marriott) diff --git a/src/channel.c b/src/channel.c --- a/src/channel.c +++ b/src/channel.c @@ -4166,8 +4166,8 @@ ch_expr_common(typval_T *argvars, typval // Move the item from the list and then change the type to // avoid the value being freed. - *rettv = list->lv_last->li_tv; - list->lv_last->li_tv.v_type = VAR_NUMBER; + *rettv = list->lv_u.mat.lv_last->li_tv; + list->lv_u.mat.lv_last->li_tv.v_type = VAR_NUMBER; free_tv(listtv); } } diff --git a/src/evalfunc.c b/src/evalfunc.c --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -4070,7 +4070,7 @@ f_index(typval_T *argvars, typval_T *ret // Start at specified item. Use the cached index that list_find() // sets, so that a negative number also works. item = list_find(l, (long)tv_get_number_chk(&argvars[2], &error)); - idx = l->lv_idx; + idx = l->lv_u.mat.lv_idx; if (argvars[3].v_type != VAR_UNKNOWN) ic = (int)tv_get_number_chk(&argvars[3], &error); if (error) @@ -4678,7 +4678,7 @@ find_some_match(typval_T *argvars, typva li = list_find(l, start); if (li == NULL) goto theend; - idx = l->lv_idx; // use the cached index + idx = l->lv_u.mat.lv_idx; // use the cached index } else { @@ -5330,9 +5330,9 @@ f_range(typval_T *argvars, typval_T *ret // works with ":for". If used otherwise range_list_materialize() must // be called. list->lv_first = &range_list_item; - list->lv_start = start; - list->lv_end = end; - list->lv_stride = stride; + list->lv_u.nonmat.lv_start = start; + list->lv_u.nonmat.lv_end = end; + list->lv_u.nonmat.lv_stride = stride; list->lv_len = (end - start) / stride + 1; } } @@ -5345,15 +5345,15 @@ range_list_materialize(list_T *list) { if (list->lv_first == &range_list_item) { - varnumber_T start = list->lv_start; - varnumber_T end = list->lv_end; - int stride = list->lv_stride; + varnumber_T start = list->lv_u.nonmat.lv_start; + varnumber_T end = list->lv_u.nonmat.lv_end; + int stride = list->lv_u.nonmat.lv_stride; varnumber_T i; list->lv_first = NULL; - list->lv_last = NULL; + list->lv_u.mat.lv_last = NULL; list->lv_len = 0; - list->lv_idx_item = NULL; + list->lv_u.mat.lv_idx_item = NULL; for (i = start; stride > 0 ? i <= end : i >= end; i += stride) if (list_append_number(list, (varnumber_T)i) == FAIL) break; diff --git a/src/evalvars.c b/src/evalvars.c --- a/src/evalvars.c +++ b/src/evalvars.c @@ -2128,7 +2128,7 @@ set_argv_var(char **argv, int argc) { if (list_append_string(l, (char_u *)argv[i], -1) == FAIL) getout(1); - l->lv_last->li_tv.v_lock = VAR_FIXED; + l->lv_u.mat.lv_last->li_tv.v_lock = VAR_FIXED; } set_vim_var_list(VV_ARGV, l); } diff --git a/src/if_mzsch.c b/src/if_mzsch.c --- a/src/if_mzsch.c +++ b/src/if_mzsch.c @@ -3044,7 +3044,7 @@ vim_to_mzscheme_impl(typval_T *vim_value MZ_GC_VAR_IN_REG(0, obj); MZ_GC_REG(); - curr = list->lv_last; + curr = list->lv_u.mat.lv_last; obj = vim_to_mzscheme_impl(&curr->li_tv, depth + 1, visited); result = scheme_make_pair(obj, scheme_null); MZ_GC_CHECK(); diff --git a/src/if_py_both.h b/src/if_py_both.h --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -2628,7 +2628,7 @@ ListAssSlice(ListObject *self, Py_ssize_ if (li) lastaddedli = li->li_prev; else - lastaddedli = l->lv_last; + lastaddedli = l->lv_u.mat.lv_last; numadded++; } clear_tv(&v); diff --git a/src/list.c b/src/list.c --- a/src/list.c +++ b/src/list.c @@ -126,7 +126,7 @@ list_alloc_with_items(int count) l->lv_len = count; l->lv_with_items = count; l->lv_first = li; - l->lv_last = li + count - 1; + l->lv_u.mat.lv_last = li + count - 1; for (i = 0; i < count; ++i) { if (i == 0) @@ -406,25 +406,25 @@ list_find(list_T *l, long n) range_list_materialize(l); // When there is a cached index may start search from there. - if (l->lv_idx_item != NULL) + if (l->lv_u.mat.lv_idx_item != NULL) { - if (n < l->lv_idx / 2) + if (n < l->lv_u.mat.lv_idx / 2) { // closest to the start of the list item = l->lv_first; idx = 0; } - else if (n > (l->lv_idx + l->lv_len) / 2) + else if (n > (l->lv_u.mat.lv_idx + l->lv_len) / 2) { // closest to the end of the list - item = l->lv_last; + item = l->lv_u.mat.lv_last; idx = l->lv_len - 1; } else { // closest to the cached index - item = l->lv_idx_item; - idx = l->lv_idx; + item = l->lv_u.mat.lv_idx_item; + idx = l->lv_u.mat.lv_idx; } } else @@ -438,7 +438,7 @@ list_find(list_T *l, long n) else { // closest to the end of the list - item = l->lv_last; + item = l->lv_u.mat.lv_last; idx = l->lv_len - 1; } } @@ -457,8 +457,8 @@ list_find(list_T *l, long n) } // cache the used index - l->lv_idx = idx; - l->lv_idx_item = item; + l->lv_u.mat.lv_idx = idx; + l->lv_u.mat.lv_idx_item = item; return item; } @@ -491,7 +491,7 @@ list_find_nr( return -1L; } - return l->lv_start + n * l->lv_stride; + return l->lv_u.nonmat.lv_start + n * l->lv_u.nonmat.lv_stride; } li = list_find(l, idx); @@ -549,18 +549,18 @@ list_idx_of_item(list_T *l, listitem_T * list_append(list_T *l, listitem_T *item) { range_list_materialize(l); - if (l->lv_last == NULL) + if (l->lv_u.mat.lv_last == NULL) { // empty list l->lv_first = item; - l->lv_last = item; + l->lv_u.mat.lv_last = item; item->li_prev = NULL; } else { - l->lv_last->li_next = item; - item->li_prev = l->lv_last; - l->lv_last = item; + l->lv_u.mat.lv_last->li_next = item; + item->li_prev = l->lv_u.mat.lv_last; + l->lv_u.mat.lv_last = item; } ++l->lv_len; item->li_next = NULL; @@ -710,12 +710,12 @@ list_insert(list_T *l, listitem_T *ni, l if (item->li_prev == NULL) { l->lv_first = ni; - ++l->lv_idx; + ++l->lv_u.mat.lv_idx; } else { item->li_prev->li_next = ni; - l->lv_idx_item = NULL; + l->lv_u.mat.lv_idx_item = NULL; } item->li_prev = ni; ++l->lv_len; @@ -846,14 +846,14 @@ vimlist_remove(list_T *l, listitem_T *it } if (item2->li_next == NULL) - l->lv_last = item->li_prev; + l->lv_u.mat.lv_last = item->li_prev; else item2->li_next->li_prev = item->li_prev; if (item->li_prev == NULL) l->lv_first = item2->li_next; else item->li_prev->li_next = item2->li_next; - l->lv_idx_item = NULL; + l->lv_u.mat.lv_idx_item = NULL; } /* @@ -1149,7 +1149,7 @@ init_static_list(staticList10_T *sl) memset(sl, 0, sizeof(staticList10_T)); l->lv_first = &sl->sl_items[0]; - l->lv_last = &sl->sl_items[9]; + l->lv_u.mat.lv_last = &sl->sl_items[9]; l->lv_refcount = DO_NOT_FREE_CNT; l->lv_lock = VAR_FIXED; sl->sl_list.lv_len = 10; @@ -1280,7 +1280,7 @@ list_remove(typval_T *argvars, typval_T { l = rettv->vval.v_list; l->lv_first = item; - l->lv_last = item2; + l->lv_u.mat.lv_last = item2; item->li_prev = NULL; item2->li_next = NULL; l->lv_len = cnt; @@ -1605,7 +1605,8 @@ do_sort_uniq(typval_T *argvars, typval_T if (!info.item_compare_func_err) { // Clear the List and append the items in sorted order. - l->lv_first = l->lv_last = l->lv_idx_item = NULL; + l->lv_first = l->lv_u.mat.lv_last + = l->lv_u.mat.lv_idx_item = NULL; l->lv_len = 0; for (i = 0; i < len; ++i) list_append(l, ptrs[i].item); @@ -1645,7 +1646,7 @@ do_sort_uniq(typval_T *argvars, typval_T if (li->li_next != NULL) li->li_next->li_prev = ptrs[i].item; else - l->lv_last = ptrs[i].item; + l->lv_u.mat.lv_last = ptrs[i].item; list_fix_watch(l, li); listitem_free(l, li); l->lv_len--; @@ -2259,16 +2260,17 @@ f_reverse(typval_T *argvars, typval_T *r { if (l->lv_first == &range_list_item) { - varnumber_T new_start = l->lv_start - + (l->lv_len - 1) * l->lv_stride; - l->lv_end = new_start - (l->lv_end - l->lv_start); - l->lv_start = new_start; - l->lv_stride = -l->lv_stride; + varnumber_T new_start = l->lv_u.nonmat.lv_start + + (l->lv_len - 1) * l->lv_u.nonmat.lv_stride; + l->lv_u.nonmat.lv_end = new_start + - (l->lv_u.nonmat.lv_end - l->lv_u.nonmat.lv_start); + l->lv_u.nonmat.lv_start = new_start; + l->lv_u.nonmat.lv_stride = -l->lv_u.nonmat.lv_stride; rettv_list_set(rettv, l); return; } - li = l->lv_last; - l->lv_first = l->lv_last = NULL; + li = l->lv_u.mat.lv_last; + l->lv_first = l->lv_u.mat.lv_last = NULL; l->lv_len = 0; while (li != NULL) { @@ -2277,7 +2279,7 @@ f_reverse(typval_T *argvars, typval_T *r li = ni; } rettv_list_set(rettv, l); - l->lv_idx = l->lv_len - l->lv_idx - 1; + l->lv_u.mat.lv_idx = l->lv_len - l->lv_u.mat.lv_idx - 1; } } diff --git a/src/structs.h b/src/structs.h --- a/src/structs.h +++ b/src/structs.h @@ -1410,13 +1410,13 @@ struct listvar_S varnumber_T lv_start; varnumber_T lv_end; int lv_stride; - }; + } nonmat; struct { // used for materialized list listitem_T *lv_last; // last item, NULL if none listitem_T *lv_idx_item; // when not NULL item at index "lv_idx" int lv_idx; // cached index of an item - }; - }; + } mat; + } lv_u; list_T *lv_copylist; // copied list used by deepcopy() list_T *lv_used_next; // next list in used lists list list_T *lv_used_prev; // previous list in used lists list diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -743,6 +743,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 173, +/**/ 172, /**/ 171, diff --git a/src/vim9compile.c b/src/vim9compile.c --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -88,7 +88,7 @@ struct scope_S { whilescope_T se_while; forscope_T se_for; tryscope_T se_try; - }; + } se_u; }; /* @@ -3506,7 +3506,7 @@ compile_if(char_u *arg, cctx_T *cctx) return NULL; // "where" is set when ":elseif", "else" or ":endif" is found - scope->se_if.is_if_label = instr->ga_len; + scope->se_u.se_if.is_if_label = instr->ga_len; generate_JUMP(cctx, JUMP_IF_FALSE, 0); return p; @@ -3528,12 +3528,12 @@ compile_elseif(char_u *arg, cctx_T *cctx cctx->ctx_locals.ga_len = scope->se_local_count; // jump from previous block to the end - if (compile_jump_to_end(&scope->se_if.is_end_label, + if (compile_jump_to_end(&scope->se_u.se_if.is_end_label, JUMP_ALWAYS, cctx) == FAIL) return NULL; // previous "if" or "elseif" jumps here - isn = ((isn_T *)instr->ga_data) + scope->se_if.is_if_label; + isn = ((isn_T *)instr->ga_data) + scope->se_u.se_if.is_if_label; isn->isn_arg.jump.jump_where = instr->ga_len; // compile "expr" @@ -3541,7 +3541,7 @@ compile_elseif(char_u *arg, cctx_T *cctx return NULL; // "where" is set when ":elseif", "else" or ":endif" is found - scope->se_if.is_if_label = instr->ga_len; + scope->se_u.se_if.is_if_label = instr->ga_len; generate_JUMP(cctx, JUMP_IF_FALSE, 0); return p; @@ -3563,12 +3563,12 @@ compile_else(char_u *arg, cctx_T *cctx) cctx->ctx_locals.ga_len = scope->se_local_count; // jump from previous block to the end - if (compile_jump_to_end(&scope->se_if.is_end_label, + if (compile_jump_to_end(&scope->se_u.se_if.is_end_label, JUMP_ALWAYS, cctx) == FAIL) return NULL; // previous "if" or "elseif" jumps here - isn = ((isn_T *)instr->ga_data) + scope->se_if.is_if_label; + isn = ((isn_T *)instr->ga_data) + scope->se_u.se_if.is_if_label; isn->isn_arg.jump.jump_where = instr->ga_len; return p; @@ -3587,12 +3587,12 @@ compile_endif(char_u *arg, cctx_T *cctx) emsg(_(e_endif_without_if)); return NULL; } - ifscope = &scope->se_if; + ifscope = &scope->se_u.se_if; cctx->ctx_scope = scope->se_outer; cctx->ctx_locals.ga_len = scope->se_local_count; // previous "if" or "elseif" jumps here - isn = ((isn_T *)instr->ga_data) + scope->se_if.is_if_label; + isn = ((isn_T *)instr->ga_data) + scope->se_u.se_if.is_if_label; isn->isn_arg.jump.jump_where = instr->ga_len; // Fill in the "end" label in jumps at the end of the blocks. @@ -3688,7 +3688,7 @@ compile_for(char_u *arg, cctx_T *cctx) } // "for_end" is set when ":endfor" is found - scope->se_for.fs_top_label = instr->ga_len; + scope->se_u.se_for.fs_top_label = instr->ga_len; generate_FOR(cctx, loop_idx); generate_STORE(cctx, ISN_STORE, var_idx, NULL); @@ -3712,7 +3712,7 @@ compile_endfor(char_u *arg, cctx_T *cctx emsg(_(e_for)); return NULL; } - forscope = &scope->se_for; + forscope = &scope->se_u.se_for; cctx->ctx_scope = scope->se_outer; cctx->ctx_locals.ga_len = scope->se_local_count; @@ -3757,14 +3757,14 @@ compile_while(char_u *arg, cctx_T *cctx) if (scope == NULL) return NULL; - scope->se_while.ws_top_label = instr->ga_len; + scope->se_u.se_while.ws_top_label = instr->ga_len; // compile "expr" if (compile_expr1(&p, cctx) == FAIL) return NULL; // "while_end" is set when ":endwhile" is found - if (compile_jump_to_end(&scope->se_while.ws_end_label, + if (compile_jump_to_end(&scope->se_u.se_while.ws_end_label, JUMP_IF_FALSE, cctx) == FAIL) return FAIL; @@ -3788,11 +3788,11 @@ compile_endwhile(char_u *arg, cctx_T *cc cctx->ctx_locals.ga_len = scope->se_local_count; // At end of ":for" scope jump back to the FOR instruction. - generate_JUMP(cctx, JUMP_ALWAYS, scope->se_while.ws_top_label); + generate_JUMP(cctx, JUMP_ALWAYS, scope->se_u.se_while.ws_top_label); // Fill in the "end" label in the WHILE statement so it can jump here. // And in any jumps for ":break" - compile_fill_jump_to_end(&scope->se_while.ws_end_label, cctx); + compile_fill_jump_to_end(&scope->se_u.se_while.ws_end_label, cctx); vim_free(scope); @@ -3821,8 +3821,8 @@ compile_continue(char_u *arg, cctx_T *cc // Jump back to the FOR or WHILE instruction. generate_JUMP(cctx, JUMP_ALWAYS, - scope->se_type == FOR_SCOPE ? scope->se_for.fs_top_label - : scope->se_while.ws_top_label); + scope->se_type == FOR_SCOPE ? scope->se_u.se_for.fs_top_label + : scope->se_u.se_while.ws_top_label); return arg; } @@ -3849,9 +3849,9 @@ compile_break(char_u *arg, cctx_T *cctx) // Jump to the end of the FOR or WHILE loop. if (scope->se_type == FOR_SCOPE) - el = &scope->se_for.fs_end_label; + el = &scope->se_u.se_for.fs_end_label; else - el = &scope->se_while.ws_end_label; + el = &scope->se_u.se_while.ws_end_label; if (compile_jump_to_end(el, JUMP_ALWAYS, cctx) == FAIL) return FAIL; @@ -3928,7 +3928,7 @@ compile_try(char_u *arg, cctx_T *cctx) // "catch" is set when the first ":catch" is found. // "finally" is set when ":finally" or ":endtry" is found - try_scope->se_try.ts_try_label = instr->ga_len; + try_scope->se_u.se_try.ts_try_label = instr->ga_len; if (generate_instr(cctx, ISN_TRY) == NULL) return NULL; @@ -3963,33 +3963,33 @@ compile_catch(char_u *arg, cctx_T *cctx return NULL; } - if (scope->se_try.ts_caught_all) + if (scope->se_u.se_try.ts_caught_all) { emsg(_("E1033: catch unreachable after catch-all")); return NULL; } // Jump from end of previous block to :finally or :endtry - if (compile_jump_to_end(&scope->se_try.ts_end_label, + if (compile_jump_to_end(&scope->se_u.se_try.ts_end_label, JUMP_ALWAYS, cctx) == FAIL) return NULL; // End :try or :catch scope: set value in ISN_TRY instruction - isn = ((isn_T *)instr->ga_data) + scope->se_try.ts_try_label; + isn = ((isn_T *)instr->ga_data) + scope->se_u.se_try.ts_try_label; if (isn->isn_arg.try.try_catch == 0) isn->isn_arg.try.try_catch = instr->ga_len; - if (scope->se_try.ts_catch_label != 0) + if (scope->se_u.se_try.ts_catch_label != 0) { // Previous catch without match jumps here - isn = ((isn_T *)instr->ga_data) + scope->se_try.ts_catch_label; + isn = ((isn_T *)instr->ga_data) + scope->se_u.se_try.ts_catch_label; isn->isn_arg.jump.jump_where = instr->ga_len; } p = skipwhite(arg); if (ends_excmd(*p)) { - scope->se_try.ts_caught_all = TRUE; - scope->se_try.ts_catch_label = 0; + scope->se_u.se_try.ts_caught_all = TRUE; + scope->se_u.se_try.ts_catch_label = 0; } else { @@ -4003,7 +4003,7 @@ compile_catch(char_u *arg, cctx_T *cctx if (generate_COMPARE(cctx, EXPR_MATCH, FALSE) == FAIL) return NULL; - scope->se_try.ts_catch_label = instr->ga_len; + scope->se_u.se_try.ts_catch_label = instr->ga_len; if (generate_JUMP(cctx, JUMP_IF_FALSE, 0) == FAIL) return NULL; } @@ -4036,7 +4036,7 @@ compile_finally(char_u *arg, cctx_T *cct } // End :catch or :finally scope: set value in ISN_TRY instruction - isn = ((isn_T *)instr->ga_data) + scope->se_try.ts_try_label; + isn = ((isn_T *)instr->ga_data) + scope->se_u.se_try.ts_try_label; if (isn->isn_arg.try.try_finally != 0) { emsg(_(e_finally_dup)); @@ -4044,12 +4044,12 @@ compile_finally(char_u *arg, cctx_T *cct } // Fill in the "end" label in jumps at the end of the blocks. - compile_fill_jump_to_end(&scope->se_try.ts_end_label, cctx); - - if (scope->se_try.ts_catch_label != 0) + compile_fill_jump_to_end(&scope->se_u.se_try.ts_end_label, cctx); + + if (scope->se_u.se_try.ts_catch_label != 0) { // Previous catch without match jumps here - isn = ((isn_T *)instr->ga_data) + scope->se_try.ts_catch_label; + isn = ((isn_T *)instr->ga_data) + scope->se_u.se_try.ts_catch_label; isn->isn_arg.jump.jump_where = instr->ga_len; } @@ -4085,7 +4085,7 @@ compile_endtry(char_u *arg, cctx_T *cctx return NULL; } - isn = ((isn_T *)instr->ga_data) + scope->se_try.ts_try_label; + isn = ((isn_T *)instr->ga_data) + scope->se_u.se_try.ts_try_label; if (isn->isn_arg.try.try_catch == 0 && isn->isn_arg.try.try_finally == 0) { emsg(_("E1032: missing :catch or :finally")); @@ -4094,7 +4094,7 @@ compile_endtry(char_u *arg, cctx_T *cctx // Fill in the "end" label in jumps at the end of the blocks, if not done // by ":finally". - compile_fill_jump_to_end(&scope->se_try.ts_end_label, cctx); + compile_fill_jump_to_end(&scope->se_u.se_try.ts_end_label, cctx); // End :catch or :finally scope: set value in ISN_TRY instruction if (isn->isn_arg.try.try_finally == 0)