struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-2133.c
blob6ac32637e12bd28f3e1b33ed0e0881c617492969
1 /* bug-2133.c
2 */
4 #include <testfwk.h>
5 #include <stdint.h>
7 typedef struct ABC { uint16_t aa, bb, cc; } ABC;
9 char __xdata buf[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };
10 ABC __xdata Abc = { 0x1111, 0x2222, 0x3333 };
12 void testBug2133(void)
14 ASSERT ( *(char*)&((*(ABC*) buf).cc) == 5); // no errors or warnings; this changes to __data pointer
15 ASSERT ( *(char*)&((*(ABC*)&buf).cc) == 5); // sub-optimal code but okay
16 ASSERT ( *(char*)&(((ABC*) buf)->cc) == 5); // uses generic pointer, otherwise okay
17 ASSERT ( *(char*)&(((ABC*)&buf)->cc) == 5); // same sub-optimal code but okay