From: John McCall Date: Tue, 19 Oct 2010 01:54:45 +0000 (+0000) Subject: Uncomputable contexts are always records but can exist. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=613ef3d4c144f8c35224daf28a187426d2044aee;p=clang Uncomputable contexts are always records but can exist. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116787 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 2b13c213e5..e7219302c1 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -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 || diff --git a/test/CXX/temp/temp.decls/temp.friend/p5.cpp b/test/CXX/temp/temp.decls/temp.friend/p5.cpp index ceefc05583..7d1ef7b2d3 100644 --- a/test/CXX/temp/temp.decls/temp.friend/p5.cpp +++ b/test/CXX/temp/temp.decls/temp.friend/p5.cpp @@ -78,3 +78,17 @@ namespace test3 { int test = A::Inner::foo(); } + +namespace test4 { + template struct X { + template void operator+=(U); + + template + template + friend void X::operator+=(U); + }; + + void test() { + X() += 1.0; + } +}