| @@ -5575,22 +5575,45 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 5574 unmodified lines |
| 5575 | struct/union init */ | 5575 | struct/union init */ |
| 5576 | /* XXX: union needs only one init */ | 5576 | /* XXX: union needs only one init */ |
| 5577 | | 5577 | |
| | 5578 | int par_count = 0; |
| 5578 | if (tok == '(') { | 5579 | if (tok == '(') { |
| 5579 | AttributeDef ad1; | 5580 | AttributeDef ad1; |
| 5580 | CType type1; | 5581 | CType type1; |
| 5581 | next(); | 5582 | next(); |
| 5582 | if (tok != '(') { | 5583 | if (tcc_state->old_struct_init_code) { |
| | 5584 | /* an old version of struct initialization. |
| | 5585 | It have a problems. But with a new version |
| | 5586 | linux 2.4.26 can't load ramdisk. |
| | 5587 | */ |
| | 5588 | while (tok == '(') { |
| | 5589 | par_count++; |
| | 5590 | next(); |
| | 5591 | } |
| | 5592 | if (!parse_btype(&type1, &ad1)) |
| | 5593 | expect("cast"); |
| | 5594 | type_decl(&type1, &ad1, &n, TYPE_ABSTRACT); |
| | 5595 | #if 0 |
| | 5596 | if (!is_assignable_types(type, &type1)) |
| | 5597 | tcc_error("invalid type for cast"); |
| | 5598 | #endif |
| | 5599 | skip(')'); |
| | 5600 | } |
| | 5601 | else |
| | 5602 | { |
| | 5603 | if (tok != '(') { |
| 5583 | if (!parse_btype(&type1, &ad1)) | 5604 | if (!parse_btype(&type1, &ad1)) |
| 5584 | expect("cast"); | 5605 | expect("cast"); |
| 5585 | type_decl(&type1, &ad1, &n, TYPE_ABSTRACT); | 5606 | type_decl(&type1, &ad1, &n, TYPE_ABSTRACT); |
| 5586 | #if 0 | 5607 | #if 0 |
| 5587 | if (!is_assignable_types(type, &type1)) | 5608 | if (!is_assignable_types(type, &type1)) |
| 5588 | tcc_error("invalid type for cast"); | 5609 | tcc_error("invalid type for cast"); |
| 5589 | #endif | 5610 | #endif |
| 5590 | skip(')'); | 5611 | skip(')'); |
| 5591 | } else | 5612 | } else |
| 5592 | unget_tok(tok); | 5613 | unget_tok(tok); |
| | 5614 | } |
| 5593 | } | 5615 | } |
| | 5616 | |
| 5594 | no_oblock = 1; | 5617 | no_oblock = 1; |
| 5595 | if (first || tok == '{') { | 5618 | if (first || tok == '{') { |
| 5596 | skip('{'); | 5619 | skip('{'); |
| @@ -5663,6 +5686,10 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 66 unmodified lines |
| 5663 | } | 5686 | } |
| 5664 | if (!no_oblock) | 5687 | if (!no_oblock) |
| 5665 | skip('}'); | 5688 | skip('}'); |
| | 5689 | while (par_count) { |
| | 5690 | skip(')'); |
| | 5691 | par_count--; |
| | 5692 | } |
| 5666 | } else if (tok == '{') { | 5693 | } else if (tok == '{') { |
| 5667 | next(); | 5694 | next(); |
| 5668 | decl_initializer(type, sec, c, first, size_only); | 5695 | decl_initializer(type, sec, c, first, size_only); |