History

Revert of the commit: fix for the array in struct initialization w/o '{', case 2 A right solution for this problem will follow.

seyko committed 11 years ago

Commit 367bb6f1 parent aba2d641 file · +9 −16Browse files

Unified · Split

tccgen.c+9−16
@@ -80,7 +80,7 @@ static int is_compatible_types(CType *type1, CType *type2); · 79 unmodified lines
8080 static int parse_btype(CType *type, AttributeDef *ad);
8181 static void type_decl(CType *type, AttributeDef *ad, int *v, int td);
8282 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);
8484 static void block(int *bsym, int *csym, int *case_sym, int *def_sym, int case_reg, int is_expr);
8585 static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, int has_init, int v, char *asm_label, int scope);
8686 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
51555155 in arrays) */
51565156 static void decl_designator(CType *type, Section *sec, unsigned long c,
51575157 int *cur_index, Sym **cur_field,
5158− int size_only, int *par_count_p)
5158+ int size_only)
51595159 {
51605160 Sym *s, *f;
51615161 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
52475247 c += f->c;
52485248 }
52495249 }
5250− decl_initializer(type, sec, c, 0, size_only, par_count_p);
5250+ decl_initializer(type, sec, c, 0, size_only);
52515251
52525252 /* XXX: make it more general */
52535253 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
54165416 dimension implicit array init handling). 'size_only' is true if
54175417 size only evaluation is wanted (only for arrays). */
54185418 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)
54205420 {
54215421 int index, array_length, n, no_oblock, nb, parlevel, parlevel1, i;
54225422 int size1, align1, expr_type;
@@ -5512,7 +5512,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 89 unmodified lines
55125512 } else {
55135513 index = 0;
55145514 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);
55165516 if (n >= 0 && index >= n)
55175517 tcc_error("index too large");
55185518 /* 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
55295529 same time) */
55305530 if (index >= n && no_oblock)
55315531 break;
5532− if (*par_count_p != 0 && tok == ')') {
5533− skip(')');
5534− *par_count_p -= 1;
5535− }
55365532 if (tok == '}')
55375533 break;
55385534 skip(',');
@@ -5589,7 +5585,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 50 unmodified lines
55895585 index = 0;
55905586 n = s->c;
55915587 while (tok != '}') {
5592− decl_designator(type, sec, c, NULL, &f, size_only, &par_count);
5588+ decl_designator(type, sec, c, NULL, &f, size_only);
55935589 index = f->c;
55945590 if (!size_only && array_length < index) {
55955591 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
56555651 par_count--;
56565652 }
56575653 } else if (tok == '{') {
5658− int par_count = 0;
56595654 next();
5660− decl_initializer(type, sec, c, first, size_only, &par_count);
5655+ decl_initializer(type, sec, c, first, size_only);
56615656 skip('}');
56625657 } else if (size_only) {
56635658 /* just skip expression */
@@ -5729,7 +5724,6 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 65 unmodified lines
57295724 initializers handling */
57305725 tok_str_new(&init_str);
57315726 if (size < 0 || (flexible_array && has_init)) {
5732− int par_count = 0;
57335727 if (!has_init)
57345728 tcc_error("unknown type size");
57355729 /* get all init string */
@@ -5765,7 +5759,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 29 unmodified lines
57655759
57665760 macro_ptr = init_str.str;
57675761 next();
5768− decl_initializer(type, NULL, 0, 1, 1, &par_count);
5762+ decl_initializer(type, NULL, 0, 1, 1);
57695763 /* prepare second initializer parsing */
57705764 macro_ptr = init_str.str;
57715765 next();
@@ -5920,8 +5914,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 148 unmodified lines
59205914 #endif
59215915 }
59225916 if (has_init || (type->t & VT_VLA)) {
5923− int par_count = 0;
5924− decl_initializer(type, sec, addr, 1, 0, &par_count);
5917+ decl_initializer(type, sec, addr, 1, 0);
59255918 /* restore parse state if needed */
59265919 if (init_str.str) {
59275920 tok_str_free(init_str.str);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t