aboutsummaryrefslogtreecommitdiff
path: root/test/SemaTemplate/instantiate-member-class.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-03-25 21:17:03 +0000
committerDouglas Gregor <dgregor@apple.com>2009-03-25 21:17:03 +0000
commitd475b8d9e6f5ff0e6ab8d15667ce8a64c7cb9a4d (patch)
tree9e94affff617c4a7717084c00c8f14f431d73bd9 /test/SemaTemplate/instantiate-member-class.cpp
parent4fcb4cd6556cd783b2a8cd2b7266ae4696e605bb (diff)
Instantiation for member classes of class templates. Note that only
the declarations of member classes are instantiated when the owning class template is instantiated. The definitions of such member classes are instantiated when a complete type is required. This change also introduces the injected-class-name into a class template specialization. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67707 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaTemplate/instantiate-member-class.cpp')
-rw-r--r--test/SemaTemplate/instantiate-member-class.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/SemaTemplate/instantiate-member-class.cpp b/test/SemaTemplate/instantiate-member-class.cpp
new file mode 100644
index 0000000000..26fddcfb34
--- /dev/null
+++ b/test/SemaTemplate/instantiate-member-class.cpp
@@ -0,0 +1,33 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+template<typename T>
+class X {
+public:
+ struct C { T &foo(); };
+
+ struct D {
+ struct E { T &bar(); };
+ struct F; // expected-note{{member is declared here}}
+ };
+};
+
+X<int>::C *c1;
+X<float>::C *c2;
+
+X<int>::X *xi;
+X<float>::X *xf;
+
+void test_naming() {
+ c1 = c2; // expected-error{{incompatible type assigning 'X<float>::C *', expected 'X<int>::C *'}}
+ xi = xf; // expected-error{{incompatible type assigning}}
+ // FIXME: error above doesn't print the type X<int>::X cleanly!
+}
+
+void test_instantiation(X<double>::C *x,
+ X<float>::D::E *e,
+ X<float>::D::F *f) {
+ double &dr = x->foo();
+ float &fr = e->bar();
+ f->foo(); // expected-error{{implicit instantiation of undefined member 'struct X<float>::D::F'}}
+
+}