aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/uninit-variables.c
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-05-10 22:10:35 +0000
committerTed Kremenek <kremenek@apple.com>2011-05-10 22:10:35 +0000
commite6c28039c63d829577a2e37170e06a1dbdf89748 (patch)
tree6ec8e6f323517b0a56df4fca315c312173e78138 /test/Sema/uninit-variables.c
parent44054452c416a622b8f19a6d157a0affc05b9aa8 (diff)
Fix crash in -Wuninitialized when using switch statments whose condition is a logical operation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131158 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/uninit-variables.c')
-rw-r--r--test/Sema/uninit-variables.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/Sema/uninit-variables.c b/test/Sema/uninit-variables.c
index 60cae802ae..b70a29519c 100644
--- a/test/Sema/uninit-variables.c
+++ b/test/Sema/uninit-variables.c
@@ -339,3 +339,16 @@ int test51(void)
return a; // no-warning
}
+// FIXME: This is a false positive, but it tests logical operations in switch statements.
+int test52(int a, int b) {
+ int x; // expected-note {{variable 'x' is declared here}} expected-note {{add initialization to silence this warning}}
+ switch (a || b) { // expected-warning {{switch condition has boolean value}}
+ case 0:
+ x = 1;
+ break;
+ case 1:
+ x = 2;
+ break;
+ }
+ return x; // expected-warning {{variable 'x' may be uninitialized when used here}}
+}