* support/regression/tests/bitfields.c:
authorborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 15 Nov 2008 17:27:17 +0000 (17:27 +0000)
committerborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 15 Nov 2008 17:27:17 +0000 (17:27 +0000)
  added test case for RFE #2291335

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5268 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCglue.c
src/pic16/glue.c
support/regression/tests/bitfields.c

index 05aa48cdba0cf98eb5e6efa493f6716e35914513..c40df2062388fcc634b9eac2b1b4990460460125 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,9 @@
 
        * src/pic16/glue.c, src/SDCC.y, src/SDCCast.c, src/SDCCglue.c,
          src/SDCCsymt.c, src/SDCCsymt.h:
-         unnamed bitfields are not initialized (gcc, msvc comatibility)
+         fixed RFE #2291335 : Unnamed bit-field initialization
+       * support/regression/tests/bitfields.c:
+         added test case for RFE #2291335
 
 2008-11-11 Raphael Neider <rneider AT web.de>
 
index 060ef51547a28d7d0ba30125c03b0ca0ec8cf7d0..c65ca88ab012e2b7e3a35f422b4c26c3ffa43a17 100644 (file)
@@ -660,6 +660,7 @@ printIvalBitFields (symbol **sym, initList **ilist, struct dbuf_s * oBuf)
       if (0 == SPEC_BLEN (lsym->etype))
         {
           /* bit-field structure member with a width of 0 */
+          lsym = lsym->next;
           break;
         }
       else if (!SPEC_BUNNAMED (lsym->etype))
@@ -744,9 +745,11 @@ printIvalStruct (symbol * sym, sym_link * type,
           if (IS_BITFIELD (sflds->type))
             printIvalBitFields(&sflds, &iloop, oBuf);
           else
-            printIval (sym, sflds->type, iloop, oBuf, 1);
-            sflds = sflds->next;
-            iloop = iloop ? iloop->next : NULL;
+            {
+              printIval (sym, sflds->type, iloop, oBuf, 1);
+              sflds = sflds->next;
+              iloop = iloop ? iloop->next : NULL;
+            }
         }
     }
 
index 374537b008356c8eba41de16afe2d110f6cb790e..2d1b53161aaf21710a6b391dacd890aecd352d36 100644 (file)
@@ -792,6 +792,7 @@ pic16_printIvalBitFields (symbol **sym, initList **ilist, char ptype, void *p)
       if (0 == SPEC_BLEN (lsym->etype))
         {
           /* bit-field structure member with a width of 0 */
+          lsym = lsym->next;
           break;
         }
       else if (!SPEC_BUNNAMED (lsym->etype))
index 1d3b2f2c2d2dc88f7392ed68f9a8ae3c22312d4a..a7882e9fd243532edbbdbc537bf368cf53294744 100644 (file)
@@ -22,7 +22,6 @@ struct {
   long l17_15 : 15;
 } l_bf;
 
-
 struct {
   unsigned int b0 : 1;
   unsigned int b1 : 1;
@@ -387,3 +386,37 @@ testSignedBitfields(void)
   ASSERT(s_bf.s8_9 > 0);
 #endif  /* !SDCC_pic16 */
 }
+
+/* test case for enhancement request #2291335 : Unnamed bit-field initialization */
+
+struct s2291335_1 {
+  int a : 2;
+  char  : 2;
+  int b : 2;
+};
+
+struct s2291335_2 {
+  int a : 2;
+  char  : 0;
+  int b : 2;
+};
+
+struct s2291335_1 gs2291335_1 = {1, 2};
+struct s2291335_2 gs2291335_2 = {1, 2};
+
+void
+__test2291335(void)
+{
+  struct s2291335_1 ls2291335_1 = {1, 2};
+  struct s2291335_2 ls2291335_2 = {1, 2};
+
+  ASSERT(gs2291335_1.a == 1);
+  ASSERT(gs2291335_1.b == 2);
+  ASSERT(gs2291335_2.a == 1);
+  ASSERT(gs2291335_2.b == 2);
+
+  ASSERT(ls2291335_1.a == 1);
+  ASSERT(ls2291335_1.b == 2);
+  ASSERT(ls2291335_2.a == 1);
+  ASSERT(ls2291335_2.b == 2);
+}