struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-3778.c
blob56ed5ffae235a295d6dd84f87e5c823c95897512
1 /** bug-3778.c: Incorrect top byte on 24-bit function pointers
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 void f1(char c, int i) __reentrant
37 j = c + i;
40 void g1(void(*ptr)(char, int) __reentrant)
42 (*ptr)(1, 2); // Topmost byte of ptr incorrectly assumed to be 0.
45 void h1(void)
47 g1(&f1);
50 void f2(char c, int i) __reentrant
52 j = c + i;
55 void g2(void(*ptr)(char, int) __reentrant)
57 (*ptr)(2, 3); // Topmost byte of ptr incorrectly assumed to be 0.
60 void h2(void)
62 g2(&f2);
65 void
66 testBug(void)
68 h1();
69 ASSERT(j == 3);
70 h2();
71 ASSERT(j == 5);