struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-2501.c.in
blobd30b5ae9baab0bc1665cd129669a7846c449ea10
1 /* bug-2501.c
2 A bug in the z80 and stm8 register allocators when dealing with results from dummy volatile long long reads via pointer.
4 type: long, long long
5 */
7 #include <testfwk.h>
9 #pragma disable_warning 85
11 typedef {type} l_t;
13 extern l_t x_llabs(l_t i);
14 extern char *x_lltoa(l_t i, char *buf, int radix);
16 struct long_s
18 unsigned long ls32;
19 unsigned long ms32;
22 union u64_s
24 l_t a;
25 struct long_s b;
28 #ifndef __SDCC_pdk14 // Lack of memory
29 char buff[10];
31 union u64_s z = {0xaa55};
32 #endif
34 void testBug(void)
36 #ifndef __SDCC_pdk14 // Lack of memory
37 z.a = x_llabs(z.a);
38 x_lltoa(z.a, buff, 10);
39 #endif
42 l_t x_llabs(l_t i)
44 return i >= 0 ? i : -1;
47 char *x_lltoa(l_t i, char *buf, int radix)
49 ASSERT (i == 0xaa55);