long l17_15 : 15;
} l_bf;
-
struct {
unsigned int b0 : 1;
unsigned int b1 : 1;
{
c_bf.c0_3 = 2;
c_bf.c3_5 = 3;
+#if defined(PORT_HOST) && (defined(__ppc__) || defined(__PPC__))
+ /* bitfields on powerpc architecture are allocated from left to right */
+ ASSERT(*(char *)(&c_bf) == ((2<<(8-3)) + 3) );
+#else
ASSERT(*(char *)(&c_bf) == (2 + (3<<3)) );
+#endif
#if 0 // not yet
i_bf.i0_7 = 23;
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);
+}