Unified · Split
| @@ -4824,7 +4824,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 4823 unmodified lines | |||
| 4824 | /* patch type size if needed */ | 4824 | /* patch type size if needed */ |
| 4825 | if (n < 0) | 4825 | if (n < 0) |
| 4826 | s->c = array_length; | 4826 | s->c = array_length; |
| 4827 | } else if ((type->t & VT_BTYPE) == VT_STRUCT && type->ref->c && /* Coo: ignore empty */ | 4827 | } else if ((type->t & VT_BTYPE) == VT_STRUCT && |
| 4828 | (sec || !first || tok == '{')) { | 4828 | (sec || !first || tok == '{')) { |
| 4829 | int par_count; | 4829 | int par_count; |
| 4830 | 4830 | ||
| @@ -4837,6 +4837,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 6 unmodified lines | |||
| 4837 | to do it correctly (ideally, the expression parser should | 4837 | to do it correctly (ideally, the expression parser should |
| 4838 | be used in all cases) */ | 4838 | be used in all cases) */ |
| 4839 | par_count = 0; | 4839 | par_count = 0; |
| 4840 | /* Coo: I think we must not deal '(' */ | ||
| 4840 | if (tok == '(') { | 4841 | if (tok == '(') { |
| 4841 | AttributeDef ad1; | 4842 | AttributeDef ad1; |
| 4842 | CType type1; | 4843 | CType type1; |
| @@ -4861,6 +4862,9 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 18 unmodified lines | |||
| 4861 | } | 4862 | } |
| 4862 | s = type->ref; | 4863 | s = type->ref; |
| 4863 | f = s->next; | 4864 | f = s->next; |
| 4865 | /* Coo: skip empty struct */ | ||
| 4866 | while (f->next && (f->type.t&VT_BTYPE)==VT_STRUCT && !f->type.ref->c) | ||
| 4867 | f=f->next; | ||
| 4864 | array_length = 0; | 4868 | array_length = 0; |
| 4865 | index = 0; | 4869 | index = 0; |
| 4866 | n = s->c; | 4870 | n = s->c; |
| @@ -4877,19 +4881,24 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 10 unmodified lines | |||
| 4877 | array_length = index; | 4881 | array_length = index; |
| 4878 | 4882 | ||
| 4879 | /* Coo: skip fields from same union */ | 4883 | /* Coo: skip fields from same union */ |
| 4880 | if ((f->type.t&VT_BITFIELD)==0) | 4884 | if (!(f->type.t&VT_BITFIELD)) |
| 4881 | bit_pos=index*8; | 4885 | bit_pos=index*8; |
| 4882 | else | 4886 | else |
| 4883 | bit_pos=f->c*8+((f->type.t>>VT_STRUCT_SHIFT)&0x3f)+((f->type.t>>(VT_STRUCT_SHIFT+6))&0x3f); | 4887 | bit_pos=f->c*8+((f->type.t>>VT_STRUCT_SHIFT)&0x3f)+((f->type.t>>(VT_STRUCT_SHIFT+6))&0x3f); |
| 4884 | while (f->next && f->next->c<index && | 4888 | do |
| 4885 | ((f->next->type.t&VT_BITFIELD)==0 || f->next->c*8+((f->next->type.t>>VT_STRUCT_SHIFT)&0x3f)<bit_pos)) | ||
| 4886 | f=f->next; | 4889 | f=f->next; |
| 4890 | while (f && (((f->type.t&VT_BTYPE)==VT_STRUCT && !f->type.ref->c) || | ||
| 4891 | f->c*8+((f->type.t&VT_BITFIELD)?((f->type.t>>VT_STRUCT_SHIFT)&0x3f):0)<bit_pos)); | ||
| 4887 | 4892 | ||
| 4888 | f = f->next; | ||
| 4889 | if (no_oblock && f == NULL) | 4893 | if (no_oblock && f == NULL) |
| 4890 | break; | 4894 | break; |
| 4891 | if (tok == '}') | 4895 | if (tok == '}') |
| 4892 | break; | 4896 | break; |
| 4897 | /* Coo: skip ')' in front of ',' for initializer */ | ||
| 4898 | while (tok==')' && par_count) { | ||
| 4899 | next(); | ||
| 4900 | par_count--; | ||
| 4901 | } | ||
| 4893 | skip(','); | 4902 | skip(','); |
| 4894 | } | 4903 | } |
| 4895 | /* put zeros at the end */ | 4904 | /* put zeros at the end */ |