static AccessResult MatchesFriend(Sema &S,
const EffectiveContext &EC,
FriendDecl *FriendD) {
- if (FriendD->isInvalidDecl())
- return AR_accessible;
-
if (TypeSourceInfo *T = FriendD->getFriendType())
return MatchesFriend(S, EC, T->getType()->getCanonicalTypeUnqualified());
FrD->setAccess(AS_public);
CurContext->addDecl(FrD);
- if (ND->isInvalidDecl()) FrD->setInvalidDecl();
-
return DeclPtrTy::make(ND);
}
// If there were at least as many template-ids as there were template
// parameter lists, then there are no template parameter lists remaining for
// the declaration itself.
- if (Idx >= NumParamLists) {
- // Silently drop template member friend declarations.
- // TODO: implement these
- if (IsFriend && NumParamLists) Invalid = true;
+ if (Idx >= NumParamLists)
return 0;
- }
// If there were too many template parameter lists, complain about that now.
if (Idx != NumParamLists - 1) {
}
}
- // Silently drop template member template friend declarations.
- // TODO: implement these
- if (IsFriend && NumParamLists > 1)
- Invalid = true;
-
// Return the last template parameter list, which corresponds to the
// entity being declared.
return ParamLists[NumParamLists - 1];
// RUN: %clang_cc1 -fsyntax-only -verify %s
-namespace test0 {
- template <class T> class A {
- class Member {};
+template <class T> class A {
+ class Member {
};
+};
- class B {
- template <class T> friend class A<T>::Member;
- };
-
- A<int> a;
- B b;
-}
-
-// rdar://problem/8204127
-namespace test1 {
- template <class T> struct A;
-
- class C {
- static void foo();
- template <class T> friend void A<T>::f();
- };
+class B {
+ template <class T> friend class A<T>::Member;
+};
- template <class T> struct A {
- void f() { C::foo(); }
- };
-
- template <class T> struct A<T*> {
- void f() { C::foo(); }
- };
-
- template <> struct A<char> {
- void f() { C::foo(); }
- };
-}
-
-// FIXME: these should fail!
-namespace test2 {
- template <class T> struct A;
-
- class C {
- static void foo();
- template <class T> friend void A<T>::g();
- };
-
- template <class T> struct A {
- void f() { C::foo(); }
- };
-
- template <class T> struct A<T*> {
- void f() { C::foo(); }
- };
-
- template <> struct A<char> {
- void f() { C::foo(); }
- };
-}
+A<int> a;
+B b;