diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-05-25 02:17:09 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-05-25 02:17:09 +0000 |
commit | 2815e1a075c74143a0b60a632090ece1dffa5c7c (patch) | |
tree | 96ee86c55336dc2f127271d108d1808da22b96ae /test/Sema/uninit-variables.c | |
parent | f8e8a3eeff891d1c056c96b6d6be404533741ba7 (diff) |
Split a chunk of -Wconditional-uninitialized warnings out into a separate flag,
-Wsometimes-uninitialized. This detects cases where an explicitly-written branch
inevitably leads to an uninitialized variable use (so either the branch is dead
code or there is an uninitialized use bug).
This chunk of warnings tentatively lives within -Wuninitialized, in order to
give it more visibility to existing Clang users.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157458 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/uninit-variables.c')
-rw-r--r-- | test/Sema/uninit-variables.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/test/Sema/uninit-variables.c b/test/Sema/uninit-variables.c index 30db640323..1be8da8148 100644 --- a/test/Sema/uninit-variables.c +++ b/test/Sema/uninit-variables.c @@ -39,17 +39,18 @@ int test6() { int test7(int y) { int x; // expected-note{{initialize the variable 'x' to silence this warning}} - if (y) + if (y) // expected-note{{uninitialized use occurs whenever 'if' condition is false}} x = 1; - return x; // expected-warning{{variable 'x' may be uninitialized when used here}} + return x; // expected-warning{{variable 'x' is sometimes uninitialized when used here}} } int test7b(int y) { int x = x; // expected-note{{variable 'x' is declared here}} if (y) x = 1; - // Warn with "may be uninitialized" here (not "is uninitialized"), since the - // self-initialization is intended to suppress a -Wuninitialized warning. + // Warn with "may be uninitialized" here (not "is sometimes uninitialized"), + // since the self-initialization is intended to suppress a -Wuninitialized + // warning. return x; // expected-warning{{variable 'x' may be uninitialized when used here}} } @@ -293,8 +294,8 @@ int test40(int x) { int test41(int x) { int y; // expected-note{{initialize the variable 'y' to silence this warning}} - if (x) y = 1; // no-warning - return y; // expected-warning {{variable 'y' may be uninitialized when used here}} + if (x) y = 1; // expected-note{{uninitialized use occurs whenever 'if' condition is false}} + return y; // expected-warning {{variable 'y' is sometimes uninitialized when used here}} } void test42() { |