aboutsummaryrefslogtreecommitdiff
path: root/tccgen.c
diff options
context:
space:
mode:
authorgrischka <grischka>2010-06-21 18:21:44 +0200
committergrischka <grischka>2010-06-21 18:21:44 +0200
commit3ba37e1e3f1d942c3115406cdccf01ce84d53bee (patch)
tree9f5aa89832abbf37bc0dc1be1c029d157f0647de /tccgen.c
parent433ecdfc9d1402ecf03e710de481e2063ad6de90 (diff)
downloadtinycc-3ba37e1e3f1d942c3115406cdccf01ce84d53bee.tar.gz
tinycc-3ba37e1e3f1d942c3115406cdccf01ce84d53bee.tar.bz2
tccgen: Revert yuanbin's recent patches
This reverts commits 670993..d35138 Maybe these commits fixed something but also seemed to cause problems.
Diffstat (limited to 'tccgen.c')
-rw-r--r--tccgen.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/tccgen.c b/tccgen.c
index 1197ff9..a7c9557 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -4867,7 +4867,6 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c,
to do it correctly (ideally, the expression parser should
be used in all cases) */
par_count = 0;
- /* Coo: I think we must not deal '(' */
if (tok == '(') {
AttributeDef ad1;
CType type1;
@@ -4892,14 +4891,10 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c,
}
s = type->ref;
f = s->next;
- /* Coo: skip empty struct */
- while (f->next && (f->type.t&VT_BTYPE)==VT_STRUCT && !f->type.ref->c)
- f=f->next;
array_length = 0;
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) {
@@ -4910,25 +4905,28 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c,
if (index > array_length)
array_length = index;
- /* Coo: skip fields from same union */
- if (!(f->type.t&VT_BITFIELD))
- 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);
- do
- f=f->next;
- while (f && (((f->type.t&VT_BTYPE)==VT_STRUCT && !f->type.ref->c) ||
- f->c*8+((f->type.t&VT_BITFIELD)?((f->type.t>>VT_STRUCT_SHIFT)&0x3f):0)<bit_pos));
+ /* gr: skip fields from same union - ugly. */
+ while (f->next) {
+ ///printf("index: %2d %08x -- %2d %08x\n", f->c, f->type.t, f->next->c, f->next->type.t);
+ /* test for same offset */
+ if (f->next->c != f->c)
+ break;
+ /* if yes, test for bitfield shift */
+ if ((f->type.t & VT_BITFIELD) && (f->next->type.t & VT_BITFIELD)) {
+ int bit_pos_1 = (f->type.t >> VT_STRUCT_SHIFT) & 0x3f;
+ int bit_pos_2 = (f->next->type.t >> VT_STRUCT_SHIFT) & 0x3f;
+ //printf("bitfield %d %d\n", bit_pos_1, bit_pos_2);
+ if (bit_pos_1 != bit_pos_2)
+ break;
+ }
+ f = f->next;
+ }
+ f = f->next;
if (no_oblock && f == NULL)
break;
if (tok == '}')
break;
- /* Coo: skip ')' in front of ',' for initializer */
- while (tok==')' && par_count) {
- next();
- par_count--;
- }
skip(',');
}
/* put zeros at the end */