Allow resolving headers from a PCH even after headers+PCH were moved to another path.
[clang.git] / test / Sema / parentheses.c
blob6d6fa1d4bd42fd5e9839b2757eb7bba76cf69e0c
1 // RUN: %clang_cc1 -Wparentheses -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -Wparentheses -fixit %s -o - | %clang_cc1 -Wparentheses -Werror -
4 // Test the various warnings under -Wparentheses
5 void if_assign(void) {
6 int i;
7 if (i = 4) {} // expected-warning {{assignment as a condition}} \
8 // expected-note{{use '==' to turn this assignment into an equality comparison}} \
9 // expected-note{{place parentheses around the assignment to silence this warning}}
10 if ((i = 4)) {}
13 void bitwise_rel(unsigned i) {
14 (void)(i & 0x2 == 0); // expected-warning {{& has lower precedence than ==}} \
15 // expected-note{{place parentheses around the & expression to evaluate it first}} \
16 // expected-note{{place parentheses around the == expression to silence this warning}}
17 (void)(0 == i & 0x2); // expected-warning {{& has lower precedence than ==}} \
18 // expected-note{{place parentheses around the & expression to evaluate it first}} \
19 // expected-note{{place parentheses around the == expression to silence this warning}}
20 (void)(i & 0xff < 30); // expected-warning {{& has lower precedence than <}} \
21 // expected-note{{place parentheses around the & expression to evaluate it first}} \
22 // expected-note{{place parentheses around the < expression to silence this warning}}
23 (void)((i & 0x2) == 0);
24 (void)(i & (0x2 == 0));
25 // Eager logical op
26 (void)(i == 1 | i == 2 | i == 3);
27 (void)(i != 1 & i != 2 & i != 3);
29 (void)(i || i && i); // expected-warning {{'&&' within '||'}} \
30 // expected-note {{place parentheses around the '&&' expression to silence this warning}}
31 (void)(i || i && "w00t"); // no warning.
32 (void)("w00t" && i || i); // no warning.
33 (void)(i || i && "w00t" || i); // expected-warning {{'&&' within '||'}} \
34 // expected-note {{place parentheses around the '&&' expression to silence this warning}}
35 (void)(i || "w00t" && i || i); // expected-warning {{'&&' within '||'}} \
36 // expected-note {{place parentheses around the '&&' expression to silence this warning}}
37 (void)(i && i || 0); // no warning.
38 (void)(0 || i && i); // no warning.