[cfe-commits] r93642 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaTemplate/friend-template.cpp

Douglas Gregor dgregor at apple.com
Sat Jan 16 10:09:53 PST 2010


Author: dgregor
Date: Sat Jan 16 12:09:52 2010
New Revision: 93642

URL: http://llvm.org/viewvc/llvm-project?rev=93642&view=rev
Log:
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.


Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/SemaTemplate/friend-template.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=93642&r1=93641&r2=93642&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Jan 16 12:09:52 2010
@@ -3362,7 +3362,8 @@
       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,

Modified: cfe/trunk/test/SemaTemplate/friend-template.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/friend-template.cpp?rev=93642&r1=93641&r2=93642&view=diff

==============================================================================
--- cfe/trunk/test/SemaTemplate/friend-template.cpp (original)
+++ cfe/trunk/test/SemaTemplate/friend-template.cpp Sat Jan 16 12:09:52 2010
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-
 // PR5057
 namespace test0 {
   namespace std {
@@ -107,3 +106,20 @@
     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);
+  };
+}
+





More information about the cfe-commits mailing list