summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-2752.c
blob: fef559e0e59bc389ca18fb14cb0e02782fa2c520 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
   bug-2752.c
   A bug in inlining of reentrant functions into nonreentrant functions in the mcs51 backend.
 */

#include <testfwk.h>

#include <stdint.h>

inline uint8_t test(uintptr_t addr) __reentrant
{
        return *(volatile uint8_t __xdata *)(addr);
}

__xdata uint8_t dat1;
uint8_t dat2;

void call(void) /* Unbalanced stack pointer in this function */
{
	dat2 = test((uintptr_t)(&dat1));
}
	
void testBug(void)
{
	dat1 = 0x5a;
	call();
	ASSERT (dat2 == 0x5a);
}

extern uint8_t test(uintptr_t addr) __reentrant;