summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2013-09-13 03:20:53 +0000
committerRichard Trieu <rtrieu@google.com>2013-09-13 03:20:53 +0000
commit1bc22c12cb8c2a7b6d2f849033a73c4befceefca (patch)
tree0918548dc1c08be68555701380e92c2e2d1992b1 /clang/test
parent7ac694e87eb30b0dcf23c4df9aeb6fde3a4b01ea (diff)
downloadbcm5719-llvm-1bc22c12cb8c2a7b6d2f849033a73c4befceefca.tar.gz
bcm5719-llvm-1bc22c12cb8c2a7b6d2f849033a73c4befceefca.zip
Refactor the uninitialized field visitor. Also moved the calls to the visitor
later in the code so that the expressions will have addition processing first. This catches a few additional cases of uninitialized uses of class fields. llvm-svn: 190657
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/SemaCXX/uninitialized.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/uninitialized.cpp b/clang/test/SemaCXX/uninitialized.cpp
index 665cfe7e911..31895c6e02c 100644
--- a/clang/test/SemaCXX/uninitialized.cpp
+++ b/clang/test/SemaCXX/uninitialized.cpp
@@ -523,3 +523,41 @@ namespace lambdas {
A a2([&] { return a2.x; }); // ok
}
}
+
+namespace record_fields {
+ struct A {
+ A() {}
+ A get();
+ static A num();
+ static A copy(A);
+ static A something(A&);
+ };
+
+ A ref(A&);
+ A const_ref(const A&);
+ A pointer(A*);
+ A normal(A);
+
+ struct B {
+ A a;
+ B(char (*)[1]) : a(a) {} // expected-warning {{uninitialized}}
+ B(char (*)[2]) : a(a.get()) {} // expected-warning {{uninitialized}}
+ B(char (*)[3]) : a(a.num()) {}
+ B(char (*)[4]) : a(a.copy(a)) {} // expected-warning {{uninitialized}}
+ B(char (*)[5]) : a(a.something(a)) {}
+ B(char (*)[6]) : a(ref(a)) {}
+ B(char (*)[7]) : a(const_ref(a)) {}
+ B(char (*)[8]) : a(pointer(&a)) {}
+ B(char (*)[9]) : a(normal(a)) {} // expected-warning {{uninitialized}}
+
+ A a1 = a1; // expected-warning {{uninitialized}}
+ A a2 = a2.get(); // expected-warning {{uninitialized}}
+ A a3 = a3.num();
+ A a4 = a4.copy(a4); // expected-warning {{uninitialized}}
+ A a5 = a5.something(a5);
+ A a6 = ref(a6);
+ A a7 = const_ref(a7);
+ A a8 = pointer(&a8);
+ A a9 = normal(a9); // expected-warning {{uninitialized}}
+ };
+}
OpenPOWER on IntegriCloud