From: maartenbrock Date: Sat, 11 Feb 2006 11:08:31 +0000 (+0000) Subject: * src/SDCCglue.c (printIvalStruct): fixed bug 1426356 union initializer X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=c02fdff56d7f28d5733180fd355e27551d04638f;p=fw%2Fsdcc * src/SDCCglue.c (printIvalStruct): fixed bug 1426356 union initializer * support/regression/tests/bug1426356.c: added * support/regression/tests/bitfields.c: removed 2 tests git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4036 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index f4901a57..9f402c12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-02-11 Maarten Brock + + * src/SDCCglue.c (printIvalStruct): fixed bug 1426356 union initializer + * support/regression/tests/bug1426356.c: added + * support/regression/tests/bitfields.c: removed 2 tests + 2006-02-10 Maarten Brock * device/include/mcs51/at89c51snd1c.h: updated comments, see patch 1428901 diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 6f76b0fd..c803c0be 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -773,11 +773,16 @@ printIvalStruct (symbol * sym, sym_link * type, iloop = ilist->init.deep; } - for (; sflds; sflds = sflds->next, iloop = (iloop ? iloop->next : NULL)) { - if (IS_BITFIELD(sflds->type)) { - printIvalBitFields(&sflds,&iloop,oFile); - } else { - printIval (sym, sflds->type, iloop, oFile); + if (SPEC_STRUCT (type)->type == UNION) { + printIval (sym, sflds->type, iloop, oFile); + iloop = iloop->next; + } else { + for (; sflds; sflds = sflds->next, iloop = (iloop ? iloop->next : NULL)) { + if (IS_BITFIELD(sflds->type)) { + printIvalBitFields(&sflds,&iloop,oFile); + } else { + printIval (sym, sflds->type, iloop, oFile); + } } } if (iloop) { diff --git a/support/regression/tests/bitfields.c b/support/regression/tests/bitfields.c index 3adc3b55..b511baa8 100644 --- a/support/regression/tests/bitfields.c +++ b/support/regression/tests/bitfields.c @@ -102,23 +102,11 @@ testBitfieldSizeof(void) ASSERT( sizeof(size1a_bf) >= 1); ASSERT( sizeof(size1b_bf) >= 1); ASSERT( sizeof(size1c_bf) >= 1); -#if !defined (__amd64__) && !defined(__CYGWIN32__) && !defined(__MINGW32__) - /* assertion fails on amd64, cygwin and mingw. - Maybe it depends on gcc version? - */ - ASSERT( sizeof(size2a_bf) >= 2); -#endif ASSERT( sizeof(size2b_bf) >= 2); ASSERT( sizeof(size2c_bf) >= 2); ASSERT( sizeof(size2d_bf) >= 2); ASSERT( sizeof(size3a_bf) >= 2); ASSERT( sizeof(size1a_bf) <= sizeof(size1b_bf)); -#if !defined (__amd64__) && !defined(__CYGWIN32__) && !defined(__MINGW32__) - /* assertion fails on amd64, cygwin and mingw. - Maybe it depends on gcc version? - */ - ASSERT( sizeof(size1a_bf) < sizeof(size2a_bf)); -#endif /* Some SDCC specific assertions. SDCC uses 8 bit storage units. Bitfields that are less than 8 bits, but would (due to earlier diff --git a/support/regression/tests/bug1426356.c b/support/regression/tests/bug1426356.c new file mode 100644 index 00000000..01caa6ae --- /dev/null +++ b/support/regression/tests/bug1426356.c @@ -0,0 +1,19 @@ +/* + bug1426356.c +*/ + +#include + +const union pu { + unsigned char t1; + unsigned char t2; +} tst[2] = {{ 1 }, { 2 }}; + +void +test_1426356(void) +{ + ASSERT( tst[0].t1 == 1 ); + ASSERT( tst[0].t2 == 1 ); + ASSERT( tst[1].t1 == 2 ); + ASSERT( tst[1].t2 == 2 ); +}