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
diff --git a/test/Sema/uninit-variables.c b/test/Sema/uninit-variables.c
index 30db640..1be8da8 100644
--- a/test/Sema/uninit-variables.c
+++ b/test/Sema/uninit-variables.c
@@ -39,17 +39,18 @@
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 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() {