History

tccgen: skip ')' in front of ',' for initializer

yuanbin committed 16 years ago

Commit d3513841 parent 952e83e1 file · +14 −5Browse files

Unified · Split

tccgen.c+14−5
@@ -4824,7 +4824,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 4823 unmodified lines
48244824 /* patch type size if needed */
48254825 if (n < 0)
48264826 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 &&
48284828 (sec || !first || tok == '{')) {
48294829 int par_count;
48304830
@@ -4837,6 +4837,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 6 unmodified lines
48374837 to do it correctly (ideally, the expression parser should
48384838 be used in all cases) */
48394839 par_count = 0;
4840+ /* Coo: I think we must not deal '(' */
48404841 if (tok == '(') {
48414842 AttributeDef ad1;
48424843 CType type1;
@@ -4861,6 +4862,9 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 18 unmodified lines
48614862 }
48624863 s = type->ref;
48634864 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;
48644868 array_length = 0;
48654869 index = 0;
48664870 n = s->c;
@@ -4877,19 +4881,24 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 10 unmodified lines
48774881 array_length = index;
48784882
48794883 /* Coo: skip fields from same union */
4880− if ((f->type.t&VT_BITFIELD)==0)
4884+ if (!(f->type.t&VT_BITFIELD))
48814885 bit_pos=index*8;
48824886 else
48834887 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
48864889 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));
48874892
4888− f = f->next;
48894893 if (no_oblock && f == NULL)
48904894 break;
48914895 if (tok == '}')
48924896 break;
4897+ /* Coo: skip ')' in front of ',' for initializer */
4898+ while (tok==')' && par_count) {
4899+ next();
4900+ par_count--;
4901+ }
48934902 skip(',');
48944903 }
48954904 /* put zeros at the end */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t