From 43a2fc7b9e0877d5aac408811bba7a1e74cb59e6 Mon Sep 17 00:00:00 2001 From: Richard Trieu Date: Wed, 9 May 2012 21:08:22 +0000 Subject: Pull some cases of initialization with self-reference warnings out of -Wconditional-uninitialized into -Wuninitialized. llvm-svn: 156512 --- clang/test/SemaCXX/uninitialized.cpp | 45 +++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) (limited to 'clang/test/SemaCXX/uninitialized.cpp') diff --git a/clang/test/SemaCXX/uninitialized.cpp b/clang/test/SemaCXX/uninitialized.cpp index b3283c221dd..a6045bd118a 100644 --- a/clang/test/SemaCXX/uninitialized.cpp +++ b/clang/test/SemaCXX/uninitialized.cpp @@ -10,9 +10,6 @@ int far(const int& x); int a = a; // no-warning: used to signal intended lack of initialization. int b = b + 1; // expected-warning {{variable 'b' is uninitialized when used within its own initialization}} int c = (c + c); // expected-warning 2 {{variable 'c' is uninitialized when used within its own initialization}} -void test() { - int d = ({ d + d ;}); // expected-warning {{variable 'd' is uninitialized when used within its own initialization}} -} int e = static_cast(e) + 1; // expected-warning {{variable 'e' is uninitialized when used within its own initialization}} int f = foo(f); // expected-warning {{variable 'f' is uninitialized when used within its own initialization}} @@ -28,6 +25,48 @@ int l = k ? l : l; // expected-warning 2{{variable 'l' is uninitialized when us int m = 1 + (k ? m : m); // expected-warning 2{{variable 'm' is uninitialized when used within its own initialization}} int n = -n; // expected-warning {{variable 'n' is uninitialized when used within its own initialization}} +void test () { + int a = a; // no-warning: used to signal intended lack of initialization. + int b = b + 1; // expected-warning {{variable 'b' is uninitialized when used within its own initialization}} + int c = (c + c); // expected-warning {{variable 'c' is uninitialized when used within its own initialization}} + int d = ({ d + d ;}); // expected-warning {{variable 'd' is uninitialized when used within its own initialization}} + int e = static_cast(e) + 1; // expected-warning {{variable 'e' is uninitialized when used within its own initialization}} + int f = foo(f); // expected-warning {{variable 'f' is uninitialized when used within its own initialization}} + + // Thes don't warn as they don't require the value. + int g = sizeof(g); + void* ptr = &ptr; + int h = bar(&h); + int i = boo(i); + int j = far(j); + int k = __alignof__(k); + + int l = k ? l : l; // FIXME: warn here + int m = 1 + (k ? m : m); // FIXME: warn here + int n = -n; // expected-warning {{variable 'n' is uninitialized when used within its own initialization}} + + for (;;) { + int a = a; // no-warning: used to signal intended lack of initialization. + int b = b + 1; // expected-warning {{variable 'b' is uninitialized when used within its own initialization}} + int c = (c + c); // expected-warning {{variable 'c' is uninitialized when used within its own initialization}} + int d = ({ d + d ;}); // expected-warning {{variable 'd' is uninitialized when used within its own initialization}} + int e = static_cast(e) + 1; // expected-warning {{variable 'e' is uninitialized when used within its own initialization}} + int f = foo(f); // expected-warning {{variable 'f' is uninitialized when used within its own initialization}} + + // Thes don't warn as they don't require the value. + int g = sizeof(g); + void* ptr = &ptr; + int h = bar(&h); + int i = boo(i); + int j = far(j); + int k = __alignof__(k); + + int l = k ? l : l; // FIXME: warn here + int m = 1 + (k ? m : m); // FIXME: warn here + int n = -n; // expected-warning {{variable 'n' is uninitialized when used within its own initialization}} + } +} + // Test self-references with record types. class A { // Non-POD class. -- cgit v1.2.3