Instantiate class template friends better; fixes PR5332.

llvm-svn: 85612
This commit is contained in:
Douglas Gregor 2009-10-30 21:07:27 +00:00
parent dc916f11b5
commit 412e8bc56d
3 changed files with 20 additions and 1 deletions

View File

@ -425,12 +425,19 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) {
= ClassTemplateDecl::Create(SemaRef.Context, Owner, D->getLocation(),
D->getIdentifier(), InstParams, RecordInst, 0);
RecordInst->setDescribedClassTemplate(Inst);
Inst->setAccess(D->getAccess());
if (D->getFriendObjectKind())
Inst->setObjectOfFriendDecl(true);
else
Inst->setAccess(D->getAccess());
Inst->setInstantiatedFromMemberTemplate(D);
// Trigger creation of the type for the instantiation.
SemaRef.Context.getTypeDeclType(RecordInst);
// We're done with friends now.
if (Inst->getFriendObjectKind())
return Inst;
Owner->addDecl(Inst);
// First, we sort the partial specializations by location, so

View File

@ -9,3 +9,5 @@ class B {
template <class T> friend class A<T>::Member;
};
A<int> a;
B b;

View File

@ -54,6 +54,7 @@ struct X1 {
template<typename U> void f2(U);
X1<int> x1i;
X0<int*> x0ip;
template<> void f2(int);
@ -62,3 +63,12 @@ template<> void f2(int);
template<typename U> void f3(U);
template<> void f3(int);
// PR5332
template <typename T>
class Foo {
template <typename U>
friend class Foo;
};
Foo<int> foo;