[cfe-commits] r99391 - in /cfe/trunk: lib/Sema/SemaAccess.cpp test/CXX/class.access/p4.cpp
John McCall
rjmccall at apple.com
Wed Mar 24 02:04:37 PDT 2010
Author: rjmccall
Date: Wed Mar 24 04:04:37 2010
New Revision: 99391
URL: http://llvm.org/viewvc/llvm-project?rev=99391&view=rev
Log:
Walk out of enums when determining effective context.
Modified:
cfe/trunk/lib/Sema/SemaAccess.cpp
cfe/trunk/test/CXX/class.access/p4.cpp
Modified: cfe/trunk/lib/Sema/SemaAccess.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAccess.cpp?rev=99391&r1=99390&r2=99391&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaAccess.cpp (original)
+++ cfe/trunk/lib/Sema/SemaAccess.cpp Wed Mar 24 04:04:37 2010
@@ -59,6 +59,9 @@
: 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 @@
}
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;
Modified: cfe/trunk/test/CXX/class.access/p4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class.access/p4.cpp?rev=99391&r1=99390&r2=99391&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class.access/p4.cpp (original)
+++ cfe/trunk/test/CXX/class.access/p4.cpp Wed Mar 24 04:04:37 2010
@@ -262,3 +262,24 @@
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
+ };
+ };
+}
More information about the cfe-commits
mailing list