struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-3126.c
blobd76d2e589b736ff6c6f871cdd8350be4f56e0f4c
1 /* bug-3126.c
2 A still-needed pointer in register pair hl was overwritten when hl was used for a stack access on gbz80.
3 */
5 #include <testfwk.h>
7 unsigned char test1;
8 unsigned char test2;
10 typedef struct _BankPtr
12 unsigned char bank;
13 unsigned int offset;
14 } BankPtr;
16 const BankPtr scene_bank_ptrs[] = {{0x06, 0x3C53}};
18 void TestFn2(unsigned char i)
20 test2 = i;
23 void TestFn(unsigned int index)
25 unsigned char bank;
26 unsigned int data_ptr;
28 bank = scene_bank_ptrs[index].bank;
29 data_ptr = scene_bank_ptrs[index].offset;
31 /* This section doesn't matter but the bug doesn't trigger without it */
32 test1 = 1;
33 TestFn2(bank);
34 /**/
36 ASSERT(data_ptr == 0x3C53);
39 void
40 testBug(void)
42 TestFn(0);