Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / bug3027957.c
blobd5dc26bfa4e541a40cd0a2ca20bbf100a1dd75bb
1 /*
2 bug3027957.c
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC_stm8
8 #define ADDRESS 0x1000
9 #elif defined(__SDCC_f8)
10 #define ADDRESS 0x3000
11 #elif defined(__SDCC_pic14)
12 #define ADDRESS 0x01A0
13 #else
14 #define ADDRESS 0xF000
15 #endif
17 #if defined(__SDCC_pic14) // Bank size limit
18 # define OFFSET_DECIMAL 70
19 # define OFFSET_HEX 0x46
20 #else
21 # define OFFSET_DECIMAL 100
22 # define OFFSET_HEX 0x64
23 #endif
25 void foo(void)
27 ((unsigned char __xdata *)ADDRESS)[OFFSET_DECIMAL] = 0x12;
30 /* bug 3034400: this should not give a warning/error */
31 char * correct(void)
33 return (char __code *) 0x1234;
36 void testBug(void)
38 #if !defined (__SDCC_pdk14) && !defined (__SDCC_pdk15) // I have no idea yet, how integers cast to pointers should behave here on pdk14
39 #ifdef __SDCC
40 foo();
41 ASSERT (*(unsigned char __xdata *)(ADDRESS + OFFSET_HEX) == 0x12);
42 #endif
43 #endif