blob: f73c60689446c62f971b38836d4845542be7590a [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}}
Mike Stumpd1969d82009-07-22 00:43:08 +000011 return 0;
Douglas Gregorcaaf29a2008-12-10 23:01:14 +000012 }
13}
14
15bool foo2() {
16 if (bool B = bar()) {
17 if (int Y = bar()) {
18 return B;
19 } else {
20 do_something(Y); // expected-warning{{'Y' is always zero in this context}}
21 return B;
22 }
23 } else {
24 if (bool B2 = B) { // expected-warning{{'B' is always false in this context}}
25 do_something(B); // expected-warning{{'B' is always false in this context}}
26 } else if (B2) { // expected-warning{{'B2' is always false in this context}}
27 do_something(B); // expected-warning{{'B' is always false in this context}}
28 }
29 return B; // expected-warning{{'B' is always false in this context}}
30 }
31}