blob: 3368da223a48ee7d0e9f12cb9f50c234ecca367f [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -fsyntax-only -verify %s
Douglas Gregorcaaf29a2008-12-10 23:01:14 +00002// rdar://6425550
3int bar();
4void do_something(int);
5
6int foo() {
7 if (int X = bar()) {
8 return X;
9 } else {
10 do_something(X); // expected-warning{{'X' is always zero in this context}}
11 }
12}
13
14bool foo2() {
15 if (bool B = bar()) {
16 if (int Y = bar()) {
17 return B;
18 } else {
19 do_something(Y); // expected-warning{{'Y' is always zero in this context}}
20 return B;
21 }
22 } else {
23 if (bool B2 = B) { // expected-warning{{'B' is always false in this context}}
24 do_something(B); // expected-warning{{'B' is always false in this context}}
25 } else if (B2) { // expected-warning{{'B2' is always false in this context}}
26 do_something(B); // expected-warning{{'B' is always false in this context}}
27 }
28 return B; // expected-warning{{'B' is always false in this context}}
29 }
30}