summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test')
-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