struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-3786.c
blobe39f8e56bfca5db230735d313beec929b5d79431
1 /** bug-3778.c: Some initalized variables placed in code segement instead of const segment.
2 */
4 #include <testfwk.h>
6 int j;
8 #if defined(__SDCC_stm8) && defined(__SDCC_MODEL_LARGE) // Fill lower 32KB of flash, so f1 or f2 is above 0x10000.
9 #define ARRAYSIZE 32000
10 long k;
11 void dummyfunc(void)
13 switch(k)
15 case 1:
16 j = (j + 1) % (j - 1);
17 case 2:
18 j = (j - 1) % (j + 1);
19 case 3:
20 j = (j + 1) % (j + 1);
21 case 4:
22 j = (j - 1) % (j - 1);
23 case 5:
24 j = (j + 2) % (j - 2);
25 case 6:
26 j = (j - 2) % (j + 2);
29 #else
30 #define ARRAYSIZE 1
31 #endif
33 const char c[ARRAYSIZE];
35 extern const unsigned int i;
37 void
38 testBug(void)
40 ASSERT(i == 0xa55a);
43 const unsigned int i = 0xa55a; // Would be placed in CODE instead of CONST.