aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/uninit-variables.c
diff options
context:
space:
mode:
authorMatt Beaumont-Gay <matthewbg@google.com>2011-10-19 18:53:03 +0000
committerMatt Beaumont-Gay <matthewbg@google.com>2011-10-19 18:53:03 +0000
commit0d381810da19dd7677b9a79fca516d298fa5addb (patch)
tree1474f30a05a13b053a81eff64f667c64343eae7d /test/Sema/uninit-variables.c
parent83da2e711902c4c54f5601c9000d646dfff06aea (diff)
Only warn at self-initialization if some later use is always uninitialized.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142538 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/uninit-variables.c')
-rw-r--r--test/Sema/uninit-variables.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/test/Sema/uninit-variables.c b/test/Sema/uninit-variables.c
index 49af4f3226..d62186df73 100644
--- a/test/Sema/uninit-variables.c
+++ b/test/Sema/uninit-variables.c
@@ -44,6 +44,15 @@ int test7(int y) {
return x; // expected-warning{{variable 'x' may be 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.
+ return x; // expected-warning{{variable 'x' may be uninitialized when used here}}
+}
+
int test8(int y) {
int x;
if (y)
@@ -415,4 +424,3 @@ void rdar9432305(float *P) {
for (; i < 10000; ++i) // expected-warning {{variable 'i' is uninitialized when used here}}
P[i] = 0.0f;
}
-