summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/uninitialized.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2014-10-22 02:52:00 +0000
committerRichard Trieu <rtrieu@google.com>2014-10-22 02:52:00 +0000
commit277ace025d5afe04ebf059017d0cae985ca3c34d (patch)
tree04e97e16e2e9bc3a3a3d0dca5e44134035eddd14 /clang/test/SemaCXX/uninitialized.cpp
parent819f391dae1873a36a8483a4f485fb18c7cf80c7 (diff)
downloadbcm5719-llvm-277ace025d5afe04ebf059017d0cae985ca3c34d.tar.gz
bcm5719-llvm-277ace025d5afe04ebf059017d0cae985ca3c34d.zip
Disable the uninitialized field warning in uninstantiated classes.
If a templated class is not instantiated, then the AST for it could be missing some things that would throw the field checker off. Wait until specialization before emitting these warnings. llvm-svn: 220363
Diffstat (limited to 'clang/test/SemaCXX/uninitialized.cpp')
-rw-r--r--clang/test/SemaCXX/uninitialized.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/uninitialized.cpp b/clang/test/SemaCXX/uninitialized.cpp
index 2596dd044de..61dabb2d001 100644
--- a/clang/test/SemaCXX/uninitialized.cpp
+++ b/clang/test/SemaCXX/uninitialized.cpp
@@ -1220,3 +1220,46 @@ namespace init_list {
{}
};
}
+
+namespace template_class {
+class Foo {
+ public:
+ int *Create() { return nullptr; }
+};
+
+template <typename T>
+class A {
+public:
+ // Don't warn on foo here.
+ A() : ptr(foo->Create()) {}
+
+private:
+ Foo *foo = new Foo;
+ int *ptr;
+};
+
+template <typename T>
+class B {
+public:
+ // foo is uninitialized here, but class B is never instantiated.
+ B() : ptr(foo->Create()) {}
+
+private:
+ Foo *foo;
+ int *ptr;
+};
+
+template <typename T>
+class C {
+public:
+ C() : ptr(foo->Create()) {}
+ // expected-warning@-1 {{field 'foo' is uninitialized when used here}}
+private:
+ Foo *foo;
+ int *ptr;
+};
+
+C<int> c;
+// expected-note@-1 {{in instantiation of member function 'template_class::C<int>::C' requested here}}
+
+}
OpenPOWER on IntegriCloud