aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaAccess.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-03-28 01:09:05 +0000
committerAnders Carlsson <andersca@mac.com>2009-03-28 01:09:05 +0000
commite5194ff24c224fa8ee83064dff73f62f745a4469 (patch)
tree5ac4e61124fdc023154bb212181e4c54640facf3 /lib/Sema/SemaAccess.cpp
parent52ba870eba17e634339622dbf103434ca31935eb (diff)
Implement access checking for protected base classes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67887 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaAccess.cpp')
-rw-r--r--lib/Sema/SemaAccess.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/Sema/SemaAccess.cpp b/lib/Sema/SemaAccess.cpp
index cc212434b7..e65b050500 100644
--- a/lib/Sema/SemaAccess.cpp
+++ b/lib/Sema/SemaAccess.cpp
@@ -55,7 +55,7 @@ bool Sema::CheckBaseClassAccess(QualType Derived, QualType Base,
const CXXBaseSpecifier *InacessibleBase = 0;
- const CXXRecordDecl* CurrentClassDecl = 0;
+ CXXRecordDecl* CurrentClassDecl = 0;
if (CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(getCurFunctionDecl()))
CurrentClassDecl = MD->getParent();
@@ -79,9 +79,21 @@ bool Sema::CheckBaseClassAccess(QualType Derived, QualType Base,
if (CurrentClassDecl != Element->Class)
FoundInaccessibleBase = true;
break;
- case AS_protected:
- // FIXME: Implement
- break;
+ case AS_protected:
+ // FIXME: Check if the current function/class is a friend.
+ if (!CurrentClassDecl) {
+ FoundInaccessibleBase = true;
+ break;
+ }
+
+ if (CurrentClassDecl != Element->Class) {
+ QualType CurrentClassType = Context.getTypeDeclType(CurrentClassDecl);
+ QualType ClassType = Context.getTypeDeclType(Element->Class);
+
+ if (!IsDerivedFrom(CurrentClassType, ClassType))
+ FoundInaccessibleBase = true;
+ break;
+ }
}
if (FoundInaccessibleBase) {