context. Fixes PR9103.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141520
91177308-0d34-0410-b5e6-
96231b3b80d8
} else if (isa<FunctionDecl>(DC)) {
FunctionDecl *Function = cast<FunctionDecl>(DC)->getCanonicalDecl();
Functions.push_back(Function);
- DC = Function->getDeclContext();
+
+ if (Function->getFriendObjectKind())
+ DC = Function->getLexicalDeclContext();
+ else
+ DC = Function->getDeclContext();
} else if (DC->isFileContext()) {
break;
} else {
void *var = static_cast<B*>(this)->mem;
}
}
+
+namespace PR9103 {
+ struct base {
+ protected:
+ static void foo(void) {}
+ };
+
+ struct cls: base {
+ friend void bar(void) {
+ base::foo();
+ }
+ };
+}
// This friendship is not considered because a public member of A is
// inaccessible in C.
namespace test13 {
- class A { protected: int foo(); }; // expected-note {{declared protected here}}
+ class A { protected: int foo(); }; // expected-note {{object type 'test13::D' must derive from context type 'test13::C'}}
class B : private virtual A {};
class C : private B { friend void test(); };
class D : public virtual A {};