1 /*
2    bug-2752.c
3    A bug in inlining of reentrant functions into nonreentrant functions in the mcs51 backend.
4  */
5 
6 #include <testfwk.h>
7 
8 #include <stdint.h>
9 
test(uintptr_t addr)10 inline uint8_t test(uintptr_t addr) __reentrant
11 {
12         return *(volatile uint8_t __xdata *)(addr);
13 }
14 
15 __xdata uint8_t dat1;
16 uint8_t dat2;
17 
call(void)18 void call(void) /* Unbalanced stack pointer in this function */
19 {
20 	dat2 = test((uintptr_t)(&dat1));
21 }
22 
testBug(void)23 void testBug(void)
24 {
25 	dat1 = 0x5a;
26 	call();
27 	ASSERT (dat2 == 0x5a);
28 }
29 
30