]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/SemaCXX/warn-for-var-in-else.cpp
Update clang to r86140.
[FreeBSD/FreeBSD.git] / test / SemaCXX / warn-for-var-in-else.cpp
1 // RUN: clang-cc -fsyntax-only -verify %s
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     return 0;
12   }
13 }
14
15 bool 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 }