This reverts commits 670993..d35138 Maybe these commits fixed something but also seemed to cause problems.
Unified · Split
| @@ -4867,7 +4867,6 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 4866 unmodified lines | |||
| 4867 | to do it correctly (ideally, the expression parser should | 4867 | to do it correctly (ideally, the expression parser should |
| 4868 | be used in all cases) */ | 4868 | be used in all cases) */ |
| 4869 | par_count = 0; | 4869 | par_count = 0; |
| 4870 | /* Coo: I think we must not deal '(' */ | ||
| 4871 | if (tok == '(') { | 4870 | if (tok == '(') { |
| 4872 | AttributeDef ad1; | 4871 | AttributeDef ad1; |
| 4873 | CType type1; | 4872 | CType type1; |
| @@ -4892,14 +4891,10 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 18 unmodified lines | |||
| 4892 | } | 4891 | } |
| 4893 | s = type->ref; | 4892 | s = type->ref; |
| 4894 | f = s->next; | 4893 | f = s->next; |
| 4895 | /* Coo: skip empty struct */ | ||
| 4896 | while (f->next && (f->type.t&VT_BTYPE)==VT_STRUCT && !f->type.ref->c) | ||
| 4897 | f=f->next; | ||
| 4898 | array_length = 0; | 4894 | array_length = 0; |
| 4899 | index = 0; | 4895 | index = 0; |
| 4900 | n = s->c; | 4896 | n = s->c; |
| 4901 | while (tok != '}') { | 4897 | while (tok != '}') { |
| 4902 | int bit_pos; | ||
| 4903 | decl_designator(type, sec, c, NULL, &f, size_only); | 4898 | decl_designator(type, sec, c, NULL, &f, size_only); |
| 4904 | index = f->c; | 4899 | index = f->c; |
| 4905 | if (!size_only && array_length < index) { | 4900 | if (!size_only && array_length < index) { |
| @@ -4910,25 +4905,28 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 4 unmodified lines | |||
| 4910 | if (index > array_length) | 4905 | if (index > array_length) |
| 4911 | array_length = index; | 4906 | array_length = index; |
| 4912 | 4907 | ||
| 4913 | /* Coo: skip fields from same union */ | 4908 | /* gr: skip fields from same union - ugly. */ |
| 4914 | if (!(f->type.t&VT_BITFIELD)) | 4909 | while (f->next) { |
| 4915 | bit_pos=index*8; | 4910 | ///printf("index: %2d %08x -- %2d %08x\n", f->c, f->type.t, f->next->c, f->next->type.t); |
| 4916 | else | 4911 | /* test for same offset */ |
| 4917 | bit_pos=f->c*8+((f->type.t>>VT_STRUCT_SHIFT)&0x3f)+((f->type.t>>(VT_STRUCT_SHIFT+6))&0x3f); | 4912 | if (f->next->c != f->c) |
| 4918 | do | 4913 | break; |
| 4919 | f=f->next; | 4914 | /* if yes, test for bitfield shift */ |
| 4920 | while (f && (((f->type.t&VT_BTYPE)==VT_STRUCT && !f->type.ref->c) || | 4915 | if ((f->type.t & VT_BITFIELD) && (f->next->type.t & VT_BITFIELD)) { |
| 4921 | f->c*8+((f->type.t&VT_BITFIELD)?((f->type.t>>VT_STRUCT_SHIFT)&0x3f):0)<bit_pos)); | 4916 | int bit_pos_1 = (f->type.t >> VT_STRUCT_SHIFT) & 0x3f; |
| 4917 | int bit_pos_2 = (f->next->type.t >> VT_STRUCT_SHIFT) & 0x3f; | ||
| 4918 | //printf("bitfield %d %d\n", bit_pos_1, bit_pos_2); | ||
| 4919 | if (bit_pos_1 != bit_pos_2) | ||
| 4920 | break; | ||
| 4921 | } | ||
| 4922 | f = f->next; | ||
| 4923 | } | ||
| 4922 | 4924 | ||
| 4925 | f = f->next; | ||
| 4923 | if (no_oblock && f == NULL) | 4926 | if (no_oblock && f == NULL) |
| 4924 | break; | 4927 | break; |
| 4925 | if (tok == '}') | 4928 | if (tok == '}') |
| 4926 | break; | 4929 | break; |
| 4927 | /* Coo: skip ')' in front of ',' for initializer */ | ||
| 4928 | while (tok==')' && par_count) { | ||
| 4929 | next(); | ||
| 4930 | par_count--; | ||
| 4931 | } | ||
| 4932 | skip(','); | 4930 | skip(','); |
| 4933 | } | 4931 | } |
| 4934 | /* put zeros at the end */ | 4932 | /* put zeros at the end */ |