diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-05-26 06:20:46 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-05-26 06:20:46 +0000 |
commit | bdb97ff687ce85e45cc728b87612ed546f48c1e7 (patch) | |
tree | 726077290e0d5b9e8de204741b6e671d11cb6f9e /test/Sema/uninit-variables.c | |
parent | 7f7c42b12ecb1560055a2c087d9ca5187ad357c3 (diff) |
In response to some discussions on IRC, tweak the wording of the new
-Wsometimes-uninitialized diagnostics to make it clearer that the cause
of the issue may be a condition which must always evaluate to true or
false, rather than an uninitialized variable.
To emphasize this, add a new note with a fixit which removes the
impossible condition or replaces it with a constant.
Also, downgrade the diagnostic from -Wsometimes-uninitialized to
-Wconditional-uninitialized when it applies to a range-based for loop,
since the condition is not written explicitly in the code in that case.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157511 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/uninit-variables.c')
-rw-r--r-- | test/Sema/uninit-variables.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/test/Sema/uninit-variables.c b/test/Sema/uninit-variables.c index 1be8da8148..ef03d44d97 100644 --- a/test/Sema/uninit-variables.c +++ b/test/Sema/uninit-variables.c @@ -39,9 +39,10 @@ int test6() { int test7(int y) { int x; // expected-note{{initialize the variable 'x' to silence this warning}} - if (y) // expected-note{{uninitialized use occurs whenever 'if' condition is false}} + if (y) // expected-warning{{variable 'x' is used uninitialized whenever 'if' condition is false}} \ + // expected-note{{remove the 'if' if its condition is always true}} x = 1; - return x; // expected-warning{{variable 'x' is sometimes uninitialized when used here}} + return x; // expected-note{{uninitialized use occurs here}} } int test7b(int y) { @@ -294,8 +295,9 @@ int test40(int x) { int test41(int x) { int y; // expected-note{{initialize the variable 'y' to silence this warning}} - 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}} + if (x) y = 1; // expected-warning{{variable 'y' is used uninitialized whenever 'if' condition is false}} \ + // expected-note{{remove the 'if' if its condition is always true}} + return y; // expected-note{{uninitialized use occurs here}} } void test42() { |