]> granicus.if.org Git - clang/commitdiff
Uncomputable contexts are always records but can exist.
authorJohn McCall <rjmccall@apple.com>
Tue, 19 Oct 2010 01:54:45 +0000 (01:54 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 19 Oct 2010 01:54:45 +0000 (01:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116787 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaType.cpp
test/CXX/temp/temp.decls/temp.friend/p5.cpp

index 2b13c213e50c2b8a64f4dd47a65237c30dae2c59..e7219302c1d1fa18800322a6717a5ef48609fd2c 100644 (file)
@@ -1408,11 +1408,15 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
     //   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 ||
index ceefc055838b015dab04e9156dc141bbf5ccc2ae..7d1ef7b2d39be41fd4189ec65a428b7e29dcbf12 100644 (file)
@@ -78,3 +78,17 @@ namespace test3 {
 
   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;
+  }
+}