]> granicus.if.org Git - clang/commitdiff
Partial fix for PR6022, where we were complaining when a friend
authorDouglas Gregor <dgregor@apple.com>
Sat, 16 Jan 2010 18:09:52 +0000 (18:09 +0000)
committerDouglas Gregor <dgregor@apple.com>
Sat, 16 Jan 2010 18:09:52 +0000 (18:09 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93642 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaTemplate/friend-template.cpp

index b308613a46f7aa23ab210ba085d82cf627906619..101cae84be65f05c34067b075d2c868b933b4230 100644 (file)
@@ -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,
index 05289b10d26cabb95a0b843e5d77331277cc5baa..8bc2631e119f31d217ef55a8a470278e6a69f34b 100644 (file)
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-
 // PR5057
 namespace test0 {
   namespace std {
@@ -107,3 +106,20 @@ namespace test5 {
     template <typename T> friend struct cache;
   };
 }
+
+// PR6022
+namespace PR6022 {
+  template <class T1, class T2 , class T3  > class A;
+
+  namespace inner {
+    template<class T1, class T2, class T3, class T> 
+    A<T1, T2, T3>& f0(A<T1, T2, T3>&, T);
+  } 
+
+  template<class T1, class T2, class T3>
+  class A {
+    template<class U1, class U2, class U3, class T>  
+    friend A<U1, U2, U3>& inner::f0(A<U1, U2, U3>&, T);
+  };
+}
+