diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-05-10 22:10:35 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-05-10 22:10:35 +0000 |
commit | efdb7fe53b14a3689a0b0fb50e5f0551aa606d15 (patch) | |
tree | e43cf9a7575177dce4cbf21877f4bc87baf6e484 /clang/test/Sema/uninit-variables.c | |
parent | a678098f246096c2dc1e392d2d25ad41daf55e1e (diff) | |
download | bcm5719-llvm-efdb7fe53b14a3689a0b0fb50e5f0551aa606d15.tar.gz bcm5719-llvm-efdb7fe53b14a3689a0b0fb50e5f0551aa606d15.zip |
Fix crash in -Wuninitialized when using switch statments whose condition is a logical operation.
llvm-svn: 131158
Diffstat (limited to 'clang/test/Sema/uninit-variables.c')
-rw-r--r-- | clang/test/Sema/uninit-variables.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/test/Sema/uninit-variables.c b/clang/test/Sema/uninit-variables.c index 60cae802ae7..b70a29519c4 100644 --- a/clang/test/Sema/uninit-variables.c +++ b/clang/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}} +} |