From 69f7586c5bebc6c70887d83e52e64620608a61a6 Mon Sep 17 00:00:00 2001 From: John McCall Date: Wed, 24 Mar 2010 09:04:37 +0000 Subject: Walk out of enums when determining effective context. llvm-svn: 99391 --- clang/lib/Sema/SemaAccess.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'clang/lib') diff --git a/clang/lib/Sema/SemaAccess.cpp b/clang/lib/Sema/SemaAccess.cpp index 5b1a9d880a9..7e2520c9eee 100644 --- a/clang/lib/Sema/SemaAccess.cpp +++ b/clang/lib/Sema/SemaAccess.cpp @@ -59,6 +59,9 @@ struct EffectiveContext { : Inner(DC), Dependent(DC->isDependentContext()) { + if (isa(DC)) + DC = cast(DC)->getDeclContext(); + if (isa(DC)) { Function = cast(DC)->getCanonicalDecl(); DC = Function->getDeclContext(); @@ -103,7 +106,14 @@ struct EffectiveContext { } static CXXRecordDecl *FindDeclaringClass(NamedDecl *D) { - CXXRecordDecl *DeclaringClass = cast(D->getDeclContext()); + DeclContext *DC = D->getDeclContext(); + + // This can only happen at top: enum decls only "publish" their + // immediate members. + if (isa(DC)) + DC = cast(DC)->getDeclContext(); + + CXXRecordDecl *DeclaringClass = cast(DC); while (DeclaringClass->isAnonymousStructOrUnion()) DeclaringClass = cast(DeclaringClass->getDeclContext()); return DeclaringClass; -- cgit v1.2.3