diff options
| author | Richard Trieu <rtrieu@google.com> | 2014-08-12 21:05:04 +0000 |
|---|---|---|
| committer | Richard Trieu <rtrieu@google.com> | 2014-08-12 21:05:04 +0000 |
| commit | 4834ad2609515295a5e4132711b1f8f263500892 (patch) | |
| tree | f7e9aafdcd6526c72a82a541ee7532a652a89240 /clang/test | |
| parent | b9ec65cd4dccd9d4a4174b0ce1308e4c4af46a3f (diff) | |
| download | bcm5719-llvm-4834ad2609515295a5e4132711b1f8f263500892.tar.gz bcm5719-llvm-4834ad2609515295a5e4132711b1f8f263500892.zip | |
Improve -Wuninitialized to catch const classes being used in their own copy
constructors.
llvm-svn: 215471
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/SemaCXX/uninitialized.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/clang/test/SemaCXX/uninitialized.cpp b/clang/test/SemaCXX/uninitialized.cpp index 677a141f3ec..7b89e5adc93 100644 --- a/clang/test/SemaCXX/uninitialized.cpp +++ b/clang/test/SemaCXX/uninitialized.cpp @@ -127,6 +127,9 @@ void setupA(bool x) { A *a26 = new A(a26->get()); // expected-warning {{variable 'a26' is uninitialized when used within its own initialization}} A *a27 = new A(a27->get2()); // expected-warning {{variable 'a27' is uninitialized when used within its own initialization}} A *a28 = new A(a28->num); // expected-warning {{variable 'a28' is uninitialized when used within its own initialization}} + + const A a29(a29); // expected-warning {{variable 'a29' is uninitialized when used within its own initialization}} + const A a30 = a30; // expected-warning {{variable 'a30' is uninitialized when used within its own initialization}} } bool x; @@ -163,6 +166,9 @@ A *a26 = new A(a26->get()); // expected-warning {{variable 'a26' is uninitial A *a27 = new A(a27->get2()); // expected-warning {{variable 'a27' is uninitialized when used within its own initialization}} A *a28 = new A(a28->num); // expected-warning {{variable 'a28' is uninitialized when used within its own initialization}} +const A a29(a29); // expected-warning {{variable 'a29' is uninitialized when used within its own initialization}} +const A a30 = a30; // expected-warning {{variable 'a30' is uninitialized when used within its own initialization}} + struct B { // POD struct. int x; @@ -209,6 +215,10 @@ void setupB() { B b17 = { b17.x = 5, b17.y = 0 }; B b18 = { b18.x + 1, b18.y }; // expected-warning 2{{variable 'b18' is uninitialized when used within its own initialization}} + + const B b19 = b19; // expected-warning {{variable 'b19' is uninitialized when used within its own initialization}} + const B b20(b20); // expected-warning {{variable 'b20' is uninitialized when used within its own initialization}} + } B b1; @@ -234,6 +244,8 @@ B* b16 = getPtrB(b16->y); // expected-warning {{variable 'b16' is uninitialized B b17 = { b17.x = 5, b17.y = 0 }; B b18 = { b18.x + 1, b18.y }; // expected-warning 2{{variable 'b18' is uninitialized when used within its own initialization}} +const B b19 = b19; // expected-warning {{variable 'b19' is uninitialized when used within its own initialization}} +const B b20(b20); // expected-warning {{variable 'b20' is uninitialized when used within its own initialization}} // Also test similar constructs in a field's initializer. struct S { @@ -385,6 +397,11 @@ namespace { G(char (*)[7]) : f3(f3->*f_ptr) {} // expected-warning {{field 'f3' is uninitialized when used here}} G(char (*)[8]) : f3(new F(f3->*ptr)) {} // expected-warning {{field 'f3' is uninitialized when used here}} }; + + struct H { + H() : a(a) {} // expected-warning {{field 'a' is uninitialized when used here}} + const A a; + }; } namespace statics { @@ -555,7 +572,7 @@ namespace record_fields { B(char (*)[9]) : a(normal(a)) {} // expected-warning {{uninitialized}} }; struct C { - C() {} // expected-note4{{in this constructor}} + C() {} // expected-note5{{in this constructor}} A a1 = a1; // expected-warning {{uninitialized}} A a2 = a2.get(); // expected-warning {{uninitialized}} A a3 = a3.num(); @@ -565,8 +582,9 @@ namespace record_fields { A a7 = const_ref(a7); A a8 = pointer(&a8); A a9 = normal(a9); // expected-warning {{uninitialized}} + const A a10 = a10; // expected-warning {{uninitialized}} }; - struct D { // expected-note4{{in the implicit default constructor}} + struct D { // expected-note5{{in the implicit default constructor}} A a1 = a1; // expected-warning {{uninitialized}} A a2 = a2.get(); // expected-warning {{uninitialized}} A a3 = a3.num(); @@ -576,6 +594,7 @@ namespace record_fields { A a7 = const_ref(a7); A a8 = pointer(&a8); A a9 = normal(a9); // expected-warning {{uninitialized}} + const A a10 = a10; // expected-warning {{uninitialized}} }; D d; struct E { @@ -588,6 +607,7 @@ namespace record_fields { A a7 = const_ref(a7); A a8 = pointer(&a8); A a9 = normal(a9); + const A a10 = a10; }; } |

