summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-2929.c
blob: 695df97d9f59d9799d2d3e4d43ece71df30d6d52 (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
32
/*
   bug-2929.c

   A bug in z80 code generation for ~.
*/

#include <testfwk.h>

volatile unsigned char c;
unsigned int i;

void f(void)
{
	unsigned int j = (unsigned char)(c + 1);
	i = ~j | 0xaa55;
}

void testBug(void)
{
	c = 0xff;
	f();
	ASSERT((i & 0xffffu) == 0xffffu);

	c = 0x00;
	f();
	ASSERT((i & 0xffffu) == 0xffffu);

	c = 0xfe;
	f();
	ASSERT((i & 0xffffu) == 0xff55u);
}