forked from OSchip/llvm-project
Walk out of enums when determining effective context.
llvm-svn: 99391
This commit is contained in:
parent
1f0479e3d7
commit
69f7586c5b
|
@ -59,6 +59,9 @@ struct EffectiveContext {
|
|||
: Inner(DC),
|
||||
Dependent(DC->isDependentContext()) {
|
||||
|
||||
if (isa<EnumDecl>(DC))
|
||||
DC = cast<EnumDecl>(DC)->getDeclContext();
|
||||
|
||||
if (isa<FunctionDecl>(DC)) {
|
||||
Function = cast<FunctionDecl>(DC)->getCanonicalDecl();
|
||||
DC = Function->getDeclContext();
|
||||
|
@ -103,7 +106,14 @@ struct EffectiveContext {
|
|||
}
|
||||
|
||||
static CXXRecordDecl *FindDeclaringClass(NamedDecl *D) {
|
||||
CXXRecordDecl *DeclaringClass = cast<CXXRecordDecl>(D->getDeclContext());
|
||||
DeclContext *DC = D->getDeclContext();
|
||||
|
||||
// This can only happen at top: enum decls only "publish" their
|
||||
// immediate members.
|
||||
if (isa<EnumDecl>(DC))
|
||||
DC = cast<EnumDecl>(DC)->getDeclContext();
|
||||
|
||||
CXXRecordDecl *DeclaringClass = cast<CXXRecordDecl>(DC);
|
||||
while (DeclaringClass->isAnonymousStructOrUnion())
|
||||
DeclaringClass = cast<CXXRecordDecl>(DeclaringClass->getDeclContext());
|
||||
return DeclaringClass;
|
||||
|
|
|
@ -262,3 +262,24 @@ namespace test9 {
|
|||
static int getX() { return x; } // expected-error {{'x' is a private member of 'test9::A'}}
|
||||
};
|
||||
}
|
||||
|
||||
namespace test10 {
|
||||
class A {
|
||||
enum {
|
||||
value = 10 // expected-note {{declared private here}}
|
||||
};
|
||||
friend class C;
|
||||
};
|
||||
|
||||
class B {
|
||||
enum {
|
||||
value = A::value // expected-error {{'value' is a private member of 'test10::A'}}
|
||||
};
|
||||
};
|
||||
|
||||
class C {
|
||||
enum {
|
||||
value = A::value
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue