[cfe-commits] r91462 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateDecl.cpp test/SemaTemplate/instantiate-member-class.cpp
John McCall
rjmccall at apple.com
Tue Dec 15 14:29:06 PST 2009
Author: rjmccall
Date: Tue Dec 15 16:29:06 2009
New Revision: 91462
URL: http://llvm.org/viewvc/llvm-project?rev=91462&view=rev
Log:
Link up member-class redeclarations during template instantiation.
This test courtesy of LLVM.
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaTemplate/instantiate-member-class.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=91462&r1=91461&r2=91462&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Tue Dec 15 16:29:06 2009
@@ -645,6 +645,12 @@
CXXRecordDecl *PrevDecl = 0;
if (D->isInjectedClassName())
PrevDecl = cast<CXXRecordDecl>(Owner);
+ else if (D->getPreviousDeclaration()) {
+ NamedDecl *Prev = SemaRef.FindInstantiatedDecl(D->getPreviousDeclaration(),
+ TemplateArgs);
+ if (!Prev) return 0;
+ PrevDecl = cast<CXXRecordDecl>(Prev);
+ }
CXXRecordDecl *Record
= CXXRecordDecl::Create(SemaRef.Context, D->getTagKind(), Owner,
Modified: cfe/trunk/test/SemaTemplate/instantiate-member-class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-member-class.cpp?rev=91462&r1=91461&r2=91462&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-member-class.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-member-class.cpp Tue Dec 15 16:29:06 2009
@@ -36,3 +36,17 @@
X<void>::C *c3; // okay
X<void>::D::E *e1; // okay
X<void>::D::E e2; // expected-note{{in instantiation of member class 'struct X<void>::D::E' requested here}}
+
+// Redeclarations.
+namespace test1 {
+ template <typename T> struct Registry {
+ class node;
+ static node *Head;
+ class node {
+ node(int v) { Head = this; }
+ };
+ };
+ void test() {
+ Registry<int>::node node(0);
+ }
+}
More information about the cfe-commits
mailing list