Showing the changes to tccgen.c (1 of 4 files). Show all
Unified · Split
| @@ -5546,33 +5546,26 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 5545 unmodified lines | ||
| 5546 | 5546 | s->c = array_length; |
| 5547 | 5547 | } else if ((type->t & VT_BTYPE) == VT_STRUCT && |
| 5548 | 5548 | (sec || !first || tok == '{')) { |
| 5549 | − int par_count; | |
| 5550 | 5549 | |
| 5551 | 5550 | /* NOTE: the previous test is a specific case for automatic |
| 5552 | 5551 | struct/union init */ |
| 5553 | 5552 | /* XXX: union needs only one init */ |
| 5554 | 5553 | |
| 5555 | − /* XXX: this test is incorrect for local initializers | |
| 5556 | − beginning with ( without {. It would be much more difficult | |
| 5557 | − to do it correctly (ideally, the expression parser should | |
| 5558 | − be used in all cases) */ | |
| 5559 | − par_count = 0; | |
| 5560 | 5554 | if (tok == '(') { |
| 5561 | 5555 | AttributeDef ad1; |
| 5562 | 5556 | CType type1; |
| 5563 | 5557 | next(); |
| 5564 | − while (tok == '(') { | |
| 5565 | − par_count++; | |
| 5566 | − next(); | |
| 5567 | − } | |
| 5568 | − if (!parse_btype(&type1, &ad1)) | |
| 5569 | − expect("cast"); | |
| 5570 | − type_decl(&type1, &ad1, &n, TYPE_ABSTRACT); | |
| 5558 | + if (tok != '(') { | |
| 5559 | + if (!parse_btype(&type1, &ad1)) | |
| 5560 | + expect("cast"); | |
| 5561 | + type_decl(&type1, &ad1, &n, TYPE_ABSTRACT); | |
| 5571 | 5562 | #if 0 |
| 5572 | − if (!is_assignable_types(type, &type1)) | |
| 5573 | − tcc_error("invalid type for cast"); | |
| 5563 | + if (!is_assignable_types(type, &type1)) | |
| 5564 | + tcc_error("invalid type for cast"); | |
| 5574 | 5565 | #endif |
| 5575 | − skip(')'); | |
| 5566 | + skip(')'); | |
| 5567 | + } else | |
| 5568 | + unget_tok(tok); | |
| 5576 | 5569 | } |
| 5577 | 5570 | no_oblock = 1; |
| 5578 | 5571 | if (first || tok == '{') { |
| @@ -5646,10 +5639,6 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 67 unmodified lines | ||
| 5646 | 5639 | } |
| 5647 | 5640 | if (!no_oblock) |
| 5648 | 5641 | skip('}'); |
| 5649 | − while (par_count) { | |
| 5650 | − skip(')'); | |
| 5651 | − par_count--; | |
| 5652 | − } | |
| 5653 | 5642 | } else if (tok == '{') { |
| 5654 | 5643 | next(); |
| 5655 | 5644 | decl_initializer(type, sec, c, first, size_only); |