* src/SDCCglue.c (printIvalStruct): fixed bug 1426356 union initializer
authormaartenbrock <maartenbrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 11 Feb 2006 11:08:31 +0000 (11:08 +0000)
committermaartenbrock <maartenbrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 11 Feb 2006 11:08:31 +0000 (11:08 +0000)
* 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

ChangeLog
src/SDCCglue.c
support/regression/tests/bitfields.c
support/regression/tests/bug1426356.c [new file with mode: 0644]

index f4901a57a105a5806635486f3dd0853cf6e27577..9f402c12a20b223736f021338b58b084d9661362 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-02-11 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * 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 <sourceforge.brock AT dse.nl>
 
        * device/include/mcs51/at89c51snd1c.h: updated comments, see patch 1428901
index 6f76b0fdc60609bd669816f91ac89f5fe5633552..c803c0be0bcce0675f6a7b600725cc839598fe94 100644 (file)
@@ -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) {
index 3adc3b55983d12a2409dd79008e7cd32be947346..b511baa8bdb46ebb2da5bc1029fdd6e76da62976 100644 (file)
@@ -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 (file)
index 0000000..01caa6a
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+   bug1426356.c
+*/
+
+#include <testfwk.h>
+
+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 );
+}