summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX/warn-for-var-in-else.cpp
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2009-11-18 14:59:57 +0000
committerrdivacky <rdivacky@FreeBSD.org>2009-11-18 14:59:57 +0000
commit741c13ecc20fb35b836ad690aeecd402f002d654 (patch)
tree60a1694bec5a44d15456acc880cb2f91619f66aa /test/SemaCXX/warn-for-var-in-else.cpp
parentb3a51061b1b9c4add078237850649f7c9efb13ab (diff)
downloadFreeBSD-src-741c13ecc20fb35b836ad690aeecd402f002d654.zip
FreeBSD-src-741c13ecc20fb35b836ad690aeecd402f002d654.tar.gz
Update clang to r89205.
Diffstat (limited to 'test/SemaCXX/warn-for-var-in-else.cpp')
-rw-r--r--test/SemaCXX/warn-for-var-in-else.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/SemaCXX/warn-for-var-in-else.cpp b/test/SemaCXX/warn-for-var-in-else.cpp
index f73c606..c46b306 100644
--- a/test/SemaCXX/warn-for-var-in-else.cpp
+++ b/test/SemaCXX/warn-for-var-in-else.cpp
@@ -2,6 +2,7 @@
// rdar://6425550
int bar();
void do_something(int);
+int *get_ptr();
int foo() {
if (int X = bar()) {
@@ -25,7 +26,20 @@ bool foo2() {
do_something(B); // expected-warning{{'B' is always false in this context}}
} else if (B2) { // expected-warning{{'B2' is always false in this context}}
do_something(B); // expected-warning{{'B' is always false in this context}}
+ do_something(B2); // expected-warning{{'B2' is always false in this context}}
}
return B; // expected-warning{{'B' is always false in this context}}
}
}
+
+void foo3() {
+ if (int *P1 = get_ptr())
+ do_something(*P1);
+ else if (int *P2 = get_ptr()) {
+ do_something(*P1); // expected-warning{{'P1' is always NULL in this context}}
+ do_something(*P2);
+ } else {
+ do_something(*P1); // expected-warning{{'P1' is always NULL in this context}}
+ do_something(*P2); // expected-warning{{'P2' is always NULL in this context}}
+ }
+}
OpenPOWER on IntegriCloud