[cfe-commits] r99554 - in /cfe/trunk: lib/Sema/SemaAccess.cpp test/CXX/class.access/class.friend/p1.cpp
John McCall
rjmccall at apple.com
Thu Mar 25 14:39:55 PDT 2010
Author: rjmccall
Date: Thu Mar 25 16:39:55 2010
New Revision: 99554
URL: http://llvm.org/viewvc/llvm-project?rev=99554&view=rev
Log:
Fix a very minor oversight in privileges-elevation: we were only considering
friendship for a derived class if the base class specifier was non-public,
and thus not considering friendship for non-public members of public bases.
Modified:
cfe/trunk/lib/Sema/SemaAccess.cpp
cfe/trunk/test/CXX/class.access/class.friend/p1.cpp
Modified: cfe/trunk/lib/Sema/SemaAccess.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAccess.cpp?rev=99554&r1=99553&r2=99554&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaAccess.cpp (original)
+++ cfe/trunk/lib/Sema/SemaAccess.cpp Thu Mar 25 16:39:55 2010
@@ -429,7 +429,7 @@
}
AccessSpecifier BaseAccess = I->Base->getAccessSpecifier();
- if (BaseAccess != AS_public) {
+ if (BaseAccess != AS_public || PathAccess != AS_public) {
switch (GetFriendKind(S, EC, I->Class)) {
case Sema::AR_inaccessible:
PathAccess = CXXRecordDecl::MergeAccess(BaseAccess, PathAccess);
Modified: cfe/trunk/test/CXX/class.access/class.friend/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class.access/class.friend/p1.cpp?rev=99554&r1=99553&r2=99554&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class.access/class.friend/p1.cpp (original)
+++ cfe/trunk/test/CXX/class.access/class.friend/p1.cpp Thu Mar 25 16:39:55 2010
@@ -149,3 +149,19 @@
// expected-error {{'getNext' is a private member of 'test2::ilist_node'}}
};
}
+
+namespace test3 {
+ class A { protected: int x; }; // expected-note {{declared protected here}}
+
+ class B : public A {
+ friend int foo(B*);
+ };
+
+ int foo(B *p) {
+ return p->x;
+ }
+
+ int foo(const B *p) {
+ return p->x; // expected-error {{'x' is a protected member of 'test3::A'}}
+ }
+}
More information about the cfe-commits
mailing list