summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaAccess.cpp20
-rw-r--r--clang/lib/Sema/SemaInherit.h2
2 files changed, 17 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaAccess.cpp b/clang/lib/Sema/SemaAccess.cpp
index cc212434b79..e65b0505002 100644
--- a/clang/lib/Sema/SemaAccess.cpp
+++ b/clang/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) {
diff --git a/clang/lib/Sema/SemaInherit.h b/clang/lib/Sema/SemaInherit.h
index 6138685b264..a164d43e8ae 100644
--- a/clang/lib/Sema/SemaInherit.h
+++ b/clang/lib/Sema/SemaInherit.h
@@ -40,7 +40,7 @@ namespace clang {
const CXXBaseSpecifier *Base;
/// Class - The record decl of the class that the base is a base of.
- const CXXRecordDecl *Class;
+ CXXRecordDecl *Class;
/// SubobjectNumber - Identifies which base class subobject (of type
/// @c Base->getType()) this base path element refers to. This
OpenPOWER on IntegriCloud