From 367bb6f4b78e4bf0cc6d89a6baf6ce1a5ef3a239 Mon Sep 17 00:00:00 2001 From: seyko Date: Mon, 23 Mar 2015 07:40:41 +0300 Subject: [PATCH] Revert of the commit: fix for the array in struct initialization w/o '{', case 2 A right solution for this problem will follow. --- tccgen.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/tccgen.c b/tccgen.c index 8c30c401..39d4566d 100644 --- a/tccgen.c +++ b/tccgen.c @@ -80,7 +80,7 @@ static int is_compatible_types(CType *type1, CType *type2); static int parse_btype(CType *type, AttributeDef *ad); static void type_decl(CType *type, AttributeDef *ad, int *v, int td); static void parse_expr_type(CType *type); -static void decl_initializer(CType *type, Section *sec, unsigned long c, int first, int size_only, int *par_count_p); +static void decl_initializer(CType *type, Section *sec, unsigned long c, int first, int size_only); static void block(int *bsym, int *csym, int *case_sym, int *def_sym, int case_reg, int is_expr); static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, int has_init, int v, char *asm_label, int scope); static int decl0(int l, int is_for_loop_init); @@ -5155,7 +5155,7 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, in arrays) */ static void decl_designator(CType *type, Section *sec, unsigned long c, int *cur_index, Sym **cur_field, - int size_only, int *par_count_p) + int size_only) { Sym *s, *f; int notfirst, index, index_last, align, l, nb_elems, elem_size; @@ -5247,7 +5247,7 @@ static void decl_designator(CType *type, Section *sec, unsigned long c, c += f->c; } } - decl_initializer(type, sec, c, 0, size_only, par_count_p); + decl_initializer(type, sec, c, 0, size_only); /* XXX: make it more general */ if (!size_only && nb_elems > 1) { @@ -5416,7 +5416,7 @@ static void init_putz(CType *t, Section *sec, unsigned long c, int size) dimension implicit array init handling). 'size_only' is true if size only evaluation is wanted (only for arrays). */ static void decl_initializer(CType *type, Section *sec, unsigned long c, - int first, int size_only, int *par_count_p) + int first, int size_only) { int index, array_length, n, no_oblock, nb, parlevel, parlevel1, i; int size1, align1, expr_type; @@ -5512,7 +5512,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, } else { index = 0; while (tok != '}') { - decl_designator(type, sec, c, &index, NULL, size_only, par_count_p); + decl_designator(type, sec, c, &index, NULL, size_only); if (n >= 0 && index >= n) tcc_error("index too large"); /* must put zero in holes (note that doing it that way @@ -5529,10 +5529,6 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, same time) */ if (index >= n && no_oblock) break; - if (*par_count_p != 0 && tok == ')') { - skip(')'); - *par_count_p -= 1; - } if (tok == '}') break; skip(','); @@ -5589,7 +5585,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, index = 0; n = s->c; while (tok != '}') { - decl_designator(type, sec, c, NULL, &f, size_only, &par_count); + decl_designator(type, sec, c, NULL, &f, size_only); index = f->c; if (!size_only && array_length < index) { init_putz(type, sec, c + array_length, @@ -5655,9 +5651,8 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, par_count--; } } else if (tok == '{') { - int par_count = 0; next(); - decl_initializer(type, sec, c, first, size_only, &par_count); + decl_initializer(type, sec, c, first, size_only); skip('}'); } else if (size_only) { /* just skip expression */ @@ -5729,7 +5724,6 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, initializers handling */ tok_str_new(&init_str); if (size < 0 || (flexible_array && has_init)) { - int par_count = 0; if (!has_init) tcc_error("unknown type size"); /* get all init string */ @@ -5765,7 +5759,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, macro_ptr = init_str.str; next(); - decl_initializer(type, NULL, 0, 1, 1, &par_count); + decl_initializer(type, NULL, 0, 1, 1); /* prepare second initializer parsing */ macro_ptr = init_str.str; next(); @@ -5920,8 +5914,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, #endif } if (has_init || (type->t & VT_VLA)) { - int par_count = 0; - decl_initializer(type, sec, addr, 1, 0, &par_count); + decl_initializer(type, sec, addr, 1, 0); /* restore parse state if needed */ if (init_str.str) { tok_str_free(init_str.str); -- 2.11.4.GIT