Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / bug-3463.c
blob50245f373903e2db3047f1184533a00fc806866d
1 /* bug-3463.c
2 A codegen issue related to writing a bit-filed to a pointer (similar to bug #3461, but this test case triggers it for different backends).
3 */
5 #include <testfwk.h>
6 #include <stdlib.h>
7 #include <stdint.h>
9 unsigned char *ptemp;
10 unsigned char temp;
12 struct {
13 unsigned char b0 : 1;
14 unsigned char b1 : 1;
15 unsigned char b2 : 1;
16 unsigned char b3 : 1;
17 unsigned char b4_7 : 4;
18 } sb_bf;
21 void
22 test(void)
24 ptemp=&temp;
25 sb_bf.b4_7=2;
26 ASSERT( sb_bf.b4_7==2 );
27 *ptemp=0xFF;
28 ASSERT( *ptemp == 0xFF );
29 *ptemp=sb_bf.b4_7;
30 ASSERT( *ptemp == 2 );
31 ASSERT( *ptemp != 0x2F );
32 *ptemp=(unsigned char) sb_bf.b4_7;
33 ASSERT( *ptemp == 2 );
34 ASSERT( *ptemp != 0x2F );
35 temp=0xFF;
36 ASSERT( temp == 0xFF );
37 temp=sb_bf.b4_7;
38 ASSERT( temp == 2 );