Uncomputable contexts are always records but can exist.

llvm-svn: 116787
This commit is contained in:
John McCall 2010-10-19 01:54:45 +00:00
parent ace48cd872
commit e3df2638ce
2 changed files with 23 additions and 5 deletions

View 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 ||

View 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;
}
}