From e1ad8a105af6d224cf791533cd88ce3e62c1de19 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sat, 16 Jan 2010 18:09:52 +0000 Subject: [PATCH] Partial fix for PR6022, where we were complaining when a friend function template declared within a class template did not match a function in another scope. We really need to rework how friends-in-templates are semantically checked. llvm-svn: 93642 --- clang/lib/Sema/SemaDecl.cpp | 3 ++- clang/test/SemaTemplate/friend-template.cpp | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index b308613a46f7..101cae84be65 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -3362,7 +3362,8 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, Diag(NewFD->getLocation(), diag::err_out_of_line_declaration) << D.getCXXScopeSpec().getRange(); NewFD->setInvalidDecl(); - } else if (!Redeclaration) { + } else if (!Redeclaration && + !(isFriend && CurContext->isDependentContext())) { // The user tried to provide an out-of-line definition for a // function that is a member of a class or namespace, but there // was no such member function declared (C++ [class.mfct]p2, diff --git a/clang/test/SemaTemplate/friend-template.cpp b/clang/test/SemaTemplate/friend-template.cpp index 05289b10d26c..8bc2631e119f 100644 --- a/clang/test/SemaTemplate/friend-template.cpp +++ b/clang/test/SemaTemplate/friend-template.cpp @@ -1,5 +1,4 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s - // PR5057 namespace test0 { namespace std { @@ -107,3 +106,20 @@ namespace test5 { template friend struct cache; }; } + +// PR6022 +namespace PR6022 { + template class A; + + namespace inner { + template + A& f0(A&, T); + } + + template + class A { + template + friend A& inner::f0(A&, T); + }; +} +