X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=support%2Fregression%2Ftests%2Fbitfields.c;h=a7882e9fd243532edbbdbc537bf368cf53294744;hb=7e7397e33149e0a075535a1a19511b00827693eb;hp=1d3b2f2c2d2dc88f7392ed68f9a8ae3c22312d4a;hpb=e8e8a99cc2a335f456ee08d0f6fc620b0b58376c;p=fw%2Fsdcc diff --git a/support/regression/tests/bitfields.c b/support/regression/tests/bitfields.c index 1d3b2f2c..a7882e9f 100644 --- a/support/regression/tests/bitfields.c +++ b/support/regression/tests/bitfields.c @@ -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); +}