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