blob: 360aade8370357cdd18fc0d998a476940e2cac6e [file] [log] [blame]
Sebastian Redl9e1d29b2009-10-26 15:24:15 +00001// RUN: clang-cc -Wparentheses -fsyntax-only -verify %s
2
3// Test the various warnings under -Wparentheses
4void if_assign(void) {
5 int i;
6 if (i = 4) {} // expected-warning {{assignment as a condition}}
7 if ((i = 4)) {}
8}
9
10void bitwise_rel(unsigned i) {
11 (void)(i & 0x2 == 0); // expected-warning {{& has lower precedence than ==}}
12 (void)(0 == i & 0x2); // expected-warning {{& has lower precedence than ==}}
13 (void)(i & 0xff < 30); // expected-warning {{& has lower precedence than <}}
14 (void)((i & 0x2) == 0);
15 (void)(i & (0x2 == 0));
16 // Eager logical op
17 (void)(i == 1 | i == 2 | i == 3);
18 (void)(i != 1 & i != 2 & i != 3);
19}