aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/uninit-variables.c
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-10-13 18:50:06 +0000
committerTed Kremenek <kremenek@apple.com>2011-10-13 18:50:06 +0000
commit9e7617220135a6f6226cf09cb242cc1b905aedb4 (patch)
tree703b7cb666fab0230627c8deb01dcfefae2d3912 /test/Sema/uninit-variables.c
parent64a371ff8d525880e519a43fc522cbdc79fc4a89 (diff)
Tweak -Wuninitialized's handling of 'int x = x' to report that as the root cause of an uninitialized variable IFF there are other uses of that uninitialized variable. Fixes <rdar://problem/9259237>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141881 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/uninit-variables.c')
-rw-r--r--test/Sema/uninit-variables.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/test/Sema/uninit-variables.c b/test/Sema/uninit-variables.c
index f716124bcb..49af4f3226 100644
--- a/test/Sema/uninit-variables.c
+++ b/test/Sema/uninit-variables.c
@@ -94,10 +94,15 @@ void test14() {
for (;;) {}
}
-int test15() {
- int x = x; // no-warning: signals intended lack of initialization. \
- // expected-note{{variable 'x' is declared here}}
- return x; // expected-warning{{variable 'x' is uninitialized when used here}}
+void test15() {
+ int x = x; // no-warning: signals intended lack of initialization.
+}
+
+int test15b() {
+ // Warn here with the self-init, since it does result in a use of
+ // an unintialized variable and this is the root cause.
+ int x = x; // expected-warning {{variable 'x' is uninitialized when used within its own initialization}}
+ return x;
}
// Don't warn in the following example; shows dataflow confluence.