aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryuanbin <Administrator@yuan.(none)>2010-06-13 02:37:28 +0800
committeryuanbin <Administrator@yuan.(none)>2010-06-13 02:37:28 +0800
commit952e83e0cabbcffc8d25699a308cd0a3df1d62ee (patch)
treecfd55ddd545526a878c5543cd645cf1772f66c2f
parentd6ce75b4d6627d5992e839460aee5de4f9743958 (diff)
downloadtinycc-952e83e0cabbcffc8d25699a308cd0a3df1d62ee.tar.gz
tinycc-952e83e0cabbcffc8d25699a308cd0a3df1d62ee.tar.bz2
tccgen: skip fields from same union
-rwxr-xr-xtccgen.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/tccgen.c b/tccgen.c
index a240937..900c775 100755
--- a/tccgen.c
+++ b/tccgen.c
@@ -4865,6 +4865,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c,
index = 0;
n = s->c;
while (tok != '}') {
+ int bit_pos;
decl_designator(type, sec, c, NULL, &f, size_only);
index = f->c;
if (!size_only && array_length < index) {
@@ -4876,8 +4877,13 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c,
array_length = index;
/* Coo: skip fields from same union */
- while (f->next && f->next->c<index)
- f=f->next;
+ if ((f->type.t&VT_BITFIELD)==0)
+ bit_pos=index*8;
+ else
+ bit_pos=f->c*8+((f->type.t>>VT_STRUCT_SHIFT)&0x3f)+((f->type.t>>(VT_STRUCT_SHIFT+6))&0x3f);
+ while (f->next && f->next->c<index &&
+ ((f->next->type.t&VT_BITFIELD)==0 || f->next->c*8+((f->next->type.t>>VT_STRUCT_SHIFT)&0x3f)<bit_pos))
+ f=f->next;
f = f->next;
if (no_oblock && f == NULL)