Unified · Split
| @@ -80,7 +80,7 @@ static int is_compatible_types(CType *type1, CType *type2); · 79 unmodified lines | |||
| 80 | static int parse_btype(CType *type, AttributeDef *ad); | 80 | static int parse_btype(CType *type, AttributeDef *ad); |
| 81 | static void type_decl(CType *type, AttributeDef *ad, int *v, int td); | 81 | static void type_decl(CType *type, AttributeDef *ad, int *v, int td); |
| 82 | static void parse_expr_type(CType *type); | 82 | static void parse_expr_type(CType *type); |
| 83 | static void decl_initializer(CType *type, Section *sec, unsigned long c, int first, int size_only, int *par_count_p); | 83 | static void decl_initializer(CType *type, Section *sec, unsigned long c, int first, int size_only); |
| 84 | static void block(int *bsym, int *csym, int *case_sym, int *def_sym, int case_reg, int is_expr); | 84 | static void block(int *bsym, int *csym, int *case_sym, int *def_sym, int case_reg, int is_expr); |
| 85 | static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, int has_init, int v, char *asm_label, int scope); | 85 | static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, int has_init, int v, char *asm_label, int scope); |
| 86 | static int decl0(int l, int is_for_loop_init); | 86 | 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, · 5068 unmodified lines | |||
| 5155 | in arrays) */ | 5155 | in arrays) */ |
| 5156 | static void decl_designator(CType *type, Section *sec, unsigned long c, | 5156 | static void decl_designator(CType *type, Section *sec, unsigned long c, |
| 5157 | int *cur_index, Sym **cur_field, | 5157 | int *cur_index, Sym **cur_field, |
| 5158 | int size_only, int *par_count_p) | 5158 | int size_only) |
| 5159 | { | 5159 | { |
| 5160 | Sym *s, *f; | 5160 | Sym *s, *f; |
| 5161 | int notfirst, index, index_last, align, l, nb_elems, elem_size; | 5161 | 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, · 85 unmodified lines | |||
| 5247 | c += f->c; | 5247 | c += f->c; |
| 5248 | } | 5248 | } |
| 5249 | } | 5249 | } |
| 5250 | decl_initializer(type, sec, c, 0, size_only, par_count_p); | 5250 | decl_initializer(type, sec, c, 0, size_only); |
| 5251 | 5251 | ||
| 5252 | /* XXX: make it more general */ | 5252 | /* XXX: make it more general */ |
| 5253 | if (!size_only && nb_elems > 1) { | 5253 | if (!size_only && nb_elems > 1) { |
| @@ -5416,7 +5416,7 @@ static void init_putz(CType *t, Section *sec, unsigned long c, int size) · 162 unmodified lines | |||
| 5416 | dimension implicit array init handling). 'size_only' is true if | 5416 | dimension implicit array init handling). 'size_only' is true if |
| 5417 | size only evaluation is wanted (only for arrays). */ | 5417 | size only evaluation is wanted (only for arrays). */ |
| 5418 | static void decl_initializer(CType *type, Section *sec, unsigned long c, | 5418 | static void decl_initializer(CType *type, Section *sec, unsigned long c, |
| 5419 | int first, int size_only, int *par_count_p) | 5419 | int first, int size_only) |
| 5420 | { | 5420 | { |
| 5421 | int index, array_length, n, no_oblock, nb, parlevel, parlevel1, i; | 5421 | int index, array_length, n, no_oblock, nb, parlevel, parlevel1, i; |
| 5422 | int size1, align1, expr_type; | 5422 | int size1, align1, expr_type; |
| @@ -5512,7 +5512,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 89 unmodified lines | |||
| 5512 | } else { | 5512 | } else { |
| 5513 | index = 0; | 5513 | index = 0; |
| 5514 | while (tok != '}') { | 5514 | while (tok != '}') { |
| 5515 | decl_designator(type, sec, c, &index, NULL, size_only, par_count_p); | 5515 | decl_designator(type, sec, c, &index, NULL, size_only); |
| 5516 | if (n >= 0 && index >= n) | 5516 | if (n >= 0 && index >= n) |
| 5517 | tcc_error("index too large"); | 5517 | tcc_error("index too large"); |
| 5518 | /* must put zero in holes (note that doing it that way | 5518 | /* 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, · 10 unmodified lines | |||
| 5529 | same time) */ | 5529 | same time) */ |
| 5530 | if (index >= n && no_oblock) | 5530 | if (index >= n && no_oblock) |
| 5531 | break; | 5531 | break; |
| 5532 | if (*par_count_p != 0 && tok == ')') { | ||
| 5533 | skip(')'); | ||
| 5534 | *par_count_p -= 1; | ||
| 5535 | } | ||
| 5536 | if (tok == '}') | 5532 | if (tok == '}') |
| 5537 | break; | 5533 | break; |
| 5538 | skip(','); | 5534 | skip(','); |
| @@ -5589,7 +5585,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 50 unmodified lines | |||
| 5589 | index = 0; | 5585 | index = 0; |
| 5590 | n = s->c; | 5586 | n = s->c; |
| 5591 | while (tok != '}') { | 5587 | while (tok != '}') { |
| 5592 | decl_designator(type, sec, c, NULL, &f, size_only, &par_count); | 5588 | decl_designator(type, sec, c, NULL, &f, size_only); |
| 5593 | index = f->c; | 5589 | index = f->c; |
| 5594 | if (!size_only && array_length < index) { | 5590 | if (!size_only && array_length < index) { |
| 5595 | init_putz(type, sec, c + array_length, | 5591 | init_putz(type, sec, c + array_length, |
| @@ -5655,9 +5651,8 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 59 unmodified lines | |||
| 5655 | par_count--; | 5651 | par_count--; |
| 5656 | } | 5652 | } |
| 5657 | } else if (tok == '{') { | 5653 | } else if (tok == '{') { |
| 5658 | int par_count = 0; | ||
| 5659 | next(); | 5654 | next(); |
| 5660 | decl_initializer(type, sec, c, first, size_only, &par_count); | 5655 | decl_initializer(type, sec, c, first, size_only); |
| 5661 | skip('}'); | 5656 | skip('}'); |
| 5662 | } else if (size_only) { | 5657 | } else if (size_only) { |
| 5663 | /* just skip expression */ | 5658 | /* just skip expression */ |
| @@ -5729,7 +5724,6 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 65 unmodified lines | |||
| 5729 | initializers handling */ | 5724 | initializers handling */ |
| 5730 | tok_str_new(&init_str); | 5725 | tok_str_new(&init_str); |
| 5731 | if (size < 0 || (flexible_array && has_init)) { | 5726 | if (size < 0 || (flexible_array && has_init)) { |
| 5732 | int par_count = 0; | ||
| 5733 | if (!has_init) | 5727 | if (!has_init) |
| 5734 | tcc_error("unknown type size"); | 5728 | tcc_error("unknown type size"); |
| 5735 | /* get all init string */ | 5729 | /* get all init string */ |
| @@ -5765,7 +5759,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 29 unmodified lines | |||
| 5765 | 5759 | ||
| 5766 | macro_ptr = init_str.str; | 5760 | macro_ptr = init_str.str; |
| 5767 | next(); | 5761 | next(); |
| 5768 | decl_initializer(type, NULL, 0, 1, 1, &par_count); | 5762 | decl_initializer(type, NULL, 0, 1, 1); |
| 5769 | /* prepare second initializer parsing */ | 5763 | /* prepare second initializer parsing */ |
| 5770 | macro_ptr = init_str.str; | 5764 | macro_ptr = init_str.str; |
| 5771 | next(); | 5765 | next(); |
| @@ -5920,8 +5914,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 148 unmodified lines | |||
| 5920 | #endif | 5914 | #endif |
| 5921 | } | 5915 | } |
| 5922 | if (has_init || (type->t & VT_VLA)) { | 5916 | if (has_init || (type->t & VT_VLA)) { |
| 5923 | int par_count = 0; | 5917 | decl_initializer(type, sec, addr, 1, 0); |
| 5924 | decl_initializer(type, sec, addr, 1, 0, &par_count); | ||
| 5925 | /* restore parse state if needed */ | 5918 | /* restore parse state if needed */ |
| 5926 | if (init_str.str) { | 5919 | if (init_str.str) { |
| 5927 | tok_str_free(init_str.str); | 5920 | tok_str_free(init_str.str); |