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
diff --git a/test/Sema/uninit-variables.c b/test/Sema/uninit-variables.c
index 49af4f32..d62186d 100644
--- a/test/Sema/uninit-variables.c
+++ b/test/Sema/uninit-variables.c
@@ -44,6 +44,15 @@
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 @@
for (; i < 10000; ++i) // expected-warning {{variable 'i' is uninitialized when used here}}
P[i] = 0.0f;
}
-