// 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 ||
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;
+ }
+}