Fix PR5716 by bandaging over the solution until we can come back to it.

I apologize for friend declarations.

llvm-svn: 91359
This commit is contained in:
John McCall 2009-12-14 23:19:40 +00:00
parent 2e1cf19924
commit 2079d0b974
2 changed files with 21 additions and 1 deletions

View File

@ -627,7 +627,12 @@ TemplateDeclInstantiator::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
InstTemplate->setAccess(D->getAccess());
assert(InstTemplate &&
"VisitFunctionDecl/CXXMethodDecl didn't create a template!");
if (!InstTemplate->getInstantiatedFromMemberTemplate())
// Link the instantiation back to the pattern *unless* this is a
// non-definition friend declaration.
if (!InstTemplate->getInstantiatedFromMemberTemplate() &&
!(InstTemplate->getFriendObjectKind() &&
!D->getTemplatedDecl()->isThisDeclarationADefinition()))
InstTemplate->setInstantiatedFromMemberTemplate(D);
// Add non-friends into the owner.

View File

@ -82,3 +82,18 @@ namespace test3 {
X3<long> x3l; // FIXME: should cause an instantiation-time failure
}
// PR5716
namespace test4 {
template<typename> struct A {
template<typename T> friend void f(const A<T>&);
};
template<typename T> void f(const A<T>&) {
int a[sizeof(T) ? -1 : -1]; // expected-error {{array size is negative}}
}
void f() {
f(A<int>()); // expected-note {{in instantiation of function template specialization}}
}
}