summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-2825.c
blob: e62ad5561b8629d4d4dd2c13c1114c9c17a1a478 (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
/*
   bug-2825.c a bug in s08 code generation that overwrote a in left shifts of 32-bit values by literals in the range [3,7];
 */

#include <testfwk.h>

unsigned char c;
unsigned long l;

void f(void)
{
	unsigned char t = c + 1; // t allocated to a

	l <<= 6; // Overwrites a.

	if(t != 1)
		f();
}

void testBug(void)
{
	c = 0;
	l = 1;
	f();

	ASSERT(l == 1ul << 6);
}