summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-2826.c
blob: 9d243e5940e78c14f22c6a10140213f2bc79961b (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
/*
   bug-2826.c
   An optimization inserted instructions in between IPUSH and CALL which resulted in wrong code for mcs51.
*/

#include <testfwk.h>

#define DS_CMD_RAM 1 << 6

unsigned char cfg_table[4];

unsigned char f(unsigned char j)
{
	static unsigned char testval = DS_CMD_RAM >> 1 | 2;
	ASSERT(j == testval);
	testval++;
	return(0);
}

void testBug(void)
{
	unsigned char i, j;
	j = DS_CMD_RAM >> 1 | 2;
	for (i = 0; i != 4; i++)
		cfg_table[i] = f(j++); // The incremented value got passed to f for mcs51.
}