summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-03-24 09:04:37 +0000
committerJohn McCall <rjmccall@apple.com>2010-03-24 09:04:37 +0000
commit69f7586c5bebc6c70887d83e52e64620608a61a6 (patch)
treee9faf46b643b3afc31646fb7a4ba5160e2c21ef3 /clang/lib/Sema
parent1f0479e3d724b5025d2bba2d25d7650b5f9a35bd (diff)
downloadbcm5719-llvm-69f7586c5bebc6c70887d83e52e64620608a61a6.tar.gz
bcm5719-llvm-69f7586c5bebc6c70887d83e52e64620608a61a6.zip
Walk out of enums when determining effective context.
llvm-svn: 99391
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaAccess.cpp12
1 files changed, 11 insertions, 1 deletions
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<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;
OpenPOWER on IntegriCloud