[cfe-commits] r116787 - in /cfe/trunk: lib/Sema/SemaType.cpp test/CXX/temp/temp.decls/temp.friend/p5.cpp

John McCall rjmccall at apple.com
Mon Oct 18 18:54:45 PDT 2010


Author: rjmccall
Date: Mon Oct 18 20:54:45 2010
New Revision: 116787

URL: http://llvm.org/viewvc/llvm-project?rev=116787&view=rev
Log:
Uncomputable contexts are always records but can exist.


Modified:
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p5.cpp

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=116787&r1=116786&r2=116787&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Mon Oct 18 20:54:45 2010
@@ -1408,11 +1408,15 @@
     //   for a nonstatic member function, the function type to which a pointer
     //   to member refers, or the top-level function type of a function typedef
     //   declaration.
-    bool FreeFunction = 
-        (D.getContext() != Declarator::MemberContext ||
-         D.getDeclSpec().isFriendSpecified()) &&
-        (!D.getCXXScopeSpec().isSet() ||
-         !computeDeclContext(D.getCXXScopeSpec(), /*FIXME:*/true)->isRecord());
+    bool FreeFunction;
+    if (!D.getCXXScopeSpec().isSet()) {
+      FreeFunction = (D.getContext() != Declarator::MemberContext ||
+                      D.getDeclSpec().isFriendSpecified());
+    } else {
+      DeclContext *DC = computeDeclContext(D.getCXXScopeSpec());
+      FreeFunction = (DC && !DC->isRecord());
+    }
+
     if (FnTy->getTypeQuals() != 0 &&
         D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_typedef &&
         (FreeFunction ||

Modified: cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p5.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p5.cpp?rev=116787&r1=116786&r2=116787&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p5.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p5.cpp Mon Oct 18 20:54:45 2010
@@ -78,3 +78,17 @@
 
   int test = A<int>::Inner::foo();
 }
+
+namespace test4 {
+  template <class T> struct X {
+    template <class U> void operator+=(U);
+    
+    template <class V>
+    template <class U>
+    friend void X<V>::operator+=(U);
+  };
+
+  void test() {   
+    X<int>() += 1.0;
+  }
+}





More information about the cfe-commits mailing list