struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-2403.c
blob9a2ebc4c46c42ac72a3d72fcc051c73b0916a101
1 /*
2 bug-2403.c
3 */
5 #include <testfwk.h>
7 #define CONST 0x09090909UL
9 typedef struct
11 unsigned char a;
12 unsigned char b;
13 unsigned int c;
14 unsigned long d;
15 unsigned long e;
16 unsigned long f;
17 } struct_one;
19 #ifndef __SDCC_pdk14 // Not enough RAM
20 __xdata struct_one test;
21 unsigned long sum;
23 unsigned long badd (__xdata struct_one *pointer)
25 sum = pointer->e + pointer->f;
26 if (sum)
27 return CONST / sum;
28 else
29 return 0;
32 unsigned long add (__xdata struct_one *pointer)
34 sum = pointer->e + pointer->f;
35 return CONST / sum;
37 #endif
39 void testBug (void)
41 #ifndef __SDCC_pdk14 // Not enough RAM
42 test.e = 0x01010101;
43 test.f = 0x02020202;
44 ASSERT (3UL == add(&test));
45 #endif