From 952e83e0cabbcffc8d25699a308cd0a3df1d62ee Mon Sep 17 00:00:00 2001 From: yuanbin Date: Sun, 13 Jun 2010 02:37:28 +0800 Subject: [PATCH] tccgen: skip fields from same union --- tccgen.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tccgen.c b/tccgen.c index a2409372..900c7759 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->cnext; + 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->cnext->type.t&VT_BITFIELD)==0 || f->next->c*8+((f->next->type.t>>VT_STRUCT_SHIFT)&0x3f)next; f = f->next; if (no_oblock && f == NULL)