summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/uninitialized.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2012-05-09 21:08:22 +0000
committerRichard Trieu <rtrieu@google.com>2012-05-09 21:08:22 +0000
commit43a2fc7b9e0877d5aac408811bba7a1e74cb59e6 (patch)
treed1ebd80f45a82df1411363a06d4d58aa1292b637 /clang/test/SemaCXX/uninitialized.cpp
parentfd02a899609e65bd8c8570901dc34fe6557073de (diff)
downloadbcm5719-llvm-43a2fc7b9e0877d5aac408811bba7a1e74cb59e6.tar.gz
bcm5719-llvm-43a2fc7b9e0877d5aac408811bba7a1e74cb59e6.zip
Pull some cases of initialization with self-reference warnings out of
-Wconditional-uninitialized into -Wuninitialized. llvm-svn: 156512
Diffstat (limited to 'clang/test/SemaCXX/uninitialized.cpp')
-rw-r--r--clang/test/SemaCXX/uninitialized.cpp45
1 files changed, 42 insertions, 3 deletions
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<long>(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<long>(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<long>(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.
OpenPOWER on IntegriCloud