struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / arithcse.c.in
blob5f4f85e728aa6b84e66a4a6f91e284b37d2469f5
1 /* Test arithmetic CSE with /+-*
3 type: char, short, long
4 attr: volatile,
5 */
7 #include <testfwk.h>
9 void
10 test_arithCse(void)
12 {attr} {type} res;
13 {attr} {type} i = 10;
15 /* addition with 0 */
16 res = i + 0;
17 ASSERT (i == 10);
19 res = 0 + i;
20 ASSERT (res == 10);
22 /* multiplication with 1 */
23 res = 1 * i;
24 ASSERT (res == 10);
26 res = i * 1;
27 ASSERT (res == 10);
29 /* multiplication with 0 */
30 res = 0 * i;
31 ASSERT (res == 0);
33 res = i * 0;
34 ASSERT (res == 0);
36 /* multiplication with -1 */
37 res = -1 * i;
38 ASSERT (res == ({type})-i);
40 res = i * -1;
41 ASSERT (res == ({type})-i);
43 /* division by 1 */
44 res = i / 1;
45 ASSERT (res == i);
47 /* division by -1 */
48 res = i / -1;
49 ASSERT (res == ({type})-i);