struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-905492.c
blob90b0131029df0358bac6e257e54e72cef081f910
1 /* bug-905492.c
3 the standard guarantees left-to-right evaluation,
4 if the first operand is unequal 0 (resp. 0), the second isn't evaluated.
5 */
7 #include <testfwk.h>
9 char a;
11 char
12 inc_a(char c)
14 a += 1;
15 return c;
18 void
19 testLeftRightAndOr(void)
21 volatile char c;
23 a = 0; c = inc_a(0) || inc_a(0); ASSERT(a == 2);
24 a = 0; c = inc_a(0) || inc_a(1); ASSERT(a == 2);
25 a = 0; c = inc_a(1) || inc_a(0); ASSERT(a == 1);
26 a = 0; c = inc_a(1) || inc_a(1); ASSERT(a == 1);
28 a = 0; c = inc_a(0) && inc_a(0); ASSERT(a == 1);
29 a = 0; c = inc_a(0) && inc_a(1); ASSERT(a == 1);
30 a = 0; c = inc_a(1) && inc_a(0); ASSERT(a == 2);
31 a = 0; c = inc_a(1) && inc_a(1); ASSERT(a == 2);