struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug1875933.c
blobc537d7cc59d0659cc5919279e07e7029496b94f4
1 /*
2 * bug1875933.c
3 */
5 #include <testfwk.h>
6 #include <stdint.h>
8 char identity(char x)
10 return x;
14 * function genAnd() and genOr() in z80/gen.c
15 * were not prepared to handle the special case where ifx == 0
18 void void_tand1(char x)
20 char y = (identity(x) & 1) ? 42 : 43;
23 void void_tand0(char x)
25 char y = (identity(x) & 0) ? 42 : 43;
28 void void_txor1(char x)
30 char y = (identity(x) ^ 1) ? 42 : 43;
33 void void_txor0(char x)
35 char y = (identity(x) ^ 0) ? 42 : 43;
40 * function genOr() in z80/gen.c
41 * assumed identity of "or a, literal" and "or a,a"
42 * that's definitely not so
45 char tor1(char x)
47 char y = (identity(x) | 1) ? 42 : 43;
48 return y;
51 char tor0(char x)
53 char y = (identity(x) | 0) ? 42 : 43;
54 return y;
57 char tand1(char x)
59 char y = (identity(x) & 1) ? 42 : 43;
60 return y;
63 char tand0(char x)
65 char y = (identity(x) & 0) ? 42 : 43;
66 return y;
69 char txor1(char x)
71 char y = (identity(x) ^ 1) ? 42 : 43;
72 return y;
75 char txor0(char x)
77 char y = (identity(x) ^ 0) ? 42 : 43;
78 return y;
82 * mcs51 segmentation fault
84 * function genOr() in mcs51/gen.c
85 * was not prepeared for ifx==0
88 void void_tor1(char x)
90 char y = (identity(x) | 1) ? 42 : 43;
93 void void_tor0(char x)
95 char y = (identity(x) | 0) ? 42 : 43;
98 void void_tor(char x)
100 char y = (identity(x) | x) ? 42 : 43;
103 void
104 testBug(void)
106 void_tand1(1);
107 void_tand1(0);
108 void_tand0(1);
109 void_tand0(0);
110 void_txor1(1);
111 void_txor0(0);
113 ASSERT(tor1(1) == 42);
114 ASSERT(tor1(0) == 42);
115 ASSERT(tor0(1) == 42);
116 ASSERT(tor0(0) == 43);
117 ASSERT(tand1(1) == 42);
118 ASSERT(tand1(0) == 43);
119 ASSERT(tand0(1) == 43);
120 ASSERT(tand0(0) == 43);
121 ASSERT(txor1(1) == 43);
122 ASSERT(txor1(0) == 42);
123 ASSERT(txor0(1) == 42);
124 ASSERT(txor0(0) == 43);
126 void_tor1(1);
127 void_tor1(0);
128 void_tor0(1);
129 void_tor0(0);
130 void_tor(0);