Daniel Dunbar | d7d5f02 | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
Douglas Gregor | caaf29a | 2008-12-10 23:01:14 +0000 | [diff] [blame] | 2 | // rdar://6425550 |
| 3 | int bar(); |
| 4 | void do_something(int); |
| 5 | |
| 6 | int 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 | |
| 14 | bool 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 | } |