diff options
Diffstat (limited to 'test/SemaCXX/uninitialized.cpp')
-rw-r--r-- | test/SemaCXX/uninitialized.cpp | 55 |
1 files changed, 35 insertions, 20 deletions
diff --git a/test/SemaCXX/uninitialized.cpp b/test/SemaCXX/uninitialized.cpp index f55f10f..2aa5662 100644 --- a/test/SemaCXX/uninitialized.cpp +++ b/test/SemaCXX/uninitialized.cpp @@ -41,8 +41,8 @@ void test_stuff () { 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 l = k ? l : l; // expected-warning {{variable 'l' is uninitialized when used within its own initialization}} + int m = 1 + (k ? m : m); // expected-warning {{'m' is uninitialized when used within its own initialization}} int n = -n; // expected-warning {{variable 'n' is uninitialized when used within its own initialization}} for (;;) { @@ -61,8 +61,8 @@ void test_stuff () { 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 l = k ? l : l; // expected-warning {{variable 'l' is uninitialized when used within its own initialization}} + int m = 1 + (k ? m : m); // expected-warning {{'m' is uninitialized when used within its own initialization}} int n = -n; // expected-warning {{variable 'n' is uninitialized when used within its own initialization}} } } @@ -406,11 +406,11 @@ namespace statics { void test() { static int a = a; // no-warning: used to signal intended lack of initialization. - static int b = b + 1; // expected-warning {{variable 'b' is uninitialized when used within its own initialization}} - static int c = (c + c); // expected-warning 2{{variable 'c' is uninitialized when used within its own initialization}} - static int d = ({ d + d ;}); // expected-warning 2{{variable 'd' is uninitialized when used within its own initialization}} - static int e = static_cast<long>(e) + 1; // expected-warning {{variable 'e' is uninitialized when used within its own initialization}} - static int f = foo(f); // expected-warning {{variable 'f' is uninitialized when used within its own initialization}} + static int b = b + 1; // expected-warning {{static variable 'b' is suspiciously used within its own initialization}} + static int c = (c + c); // expected-warning 2{{static variable 'c' is suspiciously used within its own initialization}} + static int d = ({ d + d ;}); // expected-warning 2{{static variable 'd' is suspiciously used within its own initialization}} + static int e = static_cast<long>(e) + 1; // expected-warning {{static variable 'e' is suspiciously used within its own initialization}} + static int f = foo(f); // expected-warning {{static variable 'f' is suspiciously used within its own initialization}} // Thes don't warn as they don't require the value. static int g = sizeof(g); @@ -420,16 +420,16 @@ namespace statics { static int j = far(j); static int k = __alignof__(k); - static int l = k ? l : l; // expected-warning 2{{variable 'l' is uninitialized when used within its own initialization}} - static int m = 1 + (k ? m : m); // expected-warning 2{{variable 'm' is uninitialized when used within its own initialization}} - static int n = -n; // expected-warning {{variable 'n' is uninitialized when used within its own initialization}} + static int l = k ? l : l; // expected-warning 2{{static variable 'l' is suspiciously used within its own initialization}} + static int m = 1 + (k ? m : m); // expected-warning 2{{static variable 'm' is suspiciously used within its own initialization}} + static int n = -n; // expected-warning {{static variable 'n' is suspiciously used within its own initialization}} for (;;) { static int a = a; // no-warning: used to signal intended lack of initialization. - static int b = b + 1; // expected-warning {{variable 'b' is uninitialized when used within its own initialization}} - static int c = (c + c); // expected-warning 2{{variable 'c' is uninitialized when used within its own initialization}} - static int d = ({ d + d ;}); // expected-warning 2{{variable 'd' is uninitialized when used within its own initialization}} - static int e = static_cast<long>(e) + 1; // expected-warning {{variable 'e' is uninitialized when used within its own initialization}} - static int f = foo(f); // expected-warning {{variable 'f' is uninitialized when used within its own initialization}} + static int b = b + 1; // expected-warning {{static variable 'b' is suspiciously used within its own initialization}} + static int c = (c + c); // expected-warning 2{{static variable 'c' is suspiciously used within its own initialization}} + static int d = ({ d + d ;}); // expected-warning 2{{static variable 'd' is suspiciously used within its own initialization}} + static int e = static_cast<long>(e) + 1; // expected-warning {{static variable 'e' is suspiciously used within its own initialization}} + static int f = foo(f); // expected-warning {{static variable 'f' is suspiciously used within its own initialization}} // Thes don't warn as they don't require the value. static int g = sizeof(g); @@ -439,9 +439,9 @@ namespace statics { static int j = far(j); static int k = __alignof__(k); - static int l = k ? l : l; // expected-warning 2{{variable 'l' is uninitialized when used within its own initialization}} - static int m = 1 + (k ? m : m); // expected-warning 2{{variable 'm' is uninitialized when used within its own initialization}} - static int n = -n; // expected-warning {{variable 'n' is uninitialized when used within its own initialization}} + static int l = k ? l : l; // expected-warning 2{{static variable 'l' is suspiciously used within its own initialization}} + static int m = 1 + (k ? m : m); // expected-warning 2{{static variable 'm' is suspiciously used within its own initialization}} + static int n = -n; // expected-warning {{static variable 'n' is suspiciously used within its own initialization}} } } } @@ -496,3 +496,18 @@ namespace references { int &b; }; } + +namespace operators { + struct A { + A(bool); + bool operator==(A); + }; + + A makeA(); + + A a1 = a1 = makeA(); // expected-warning{{variable 'a1' is uninitialized when used within its own initialization}} + A a2 = a2 == a1; // expected-warning{{variable 'a2' is uninitialized when used within its own initialization}} + A a3 = a2 == a3; // expected-warning{{variable 'a3' is uninitialized when used within its own initialization}} + + int x = x = 5; +} |