It is OK to cast to a private base class if the current member belongs to the class that the private base class is a base of:

class A {};
class B : private A {
  void f(B *b) { A* a = b; }
};



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67860 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaAccess.cpp b/lib/Sema/SemaAccess.cpp
index 85e1c2e..cc21243 100644
--- a/lib/Sema/SemaAccess.cpp
+++ b/lib/Sema/SemaAccess.cpp
@@ -55,6 +55,10 @@
   
   const CXXBaseSpecifier *InacessibleBase = 0;
 
+  const CXXRecordDecl* CurrentClassDecl = 0;
+  if (CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(getCurFunctionDecl()))
+    CurrentClassDecl = MD->getParent();
+
   for (BasePaths::paths_iterator Path = Paths.begin(), PathsEnd = Paths.end(); 
       Path != PathsEnd; ++Path) {
     
@@ -71,8 +75,9 @@
         // Nothing to do.
         break;
       case AS_private:
-        // FIXME: Check if the current function is a member or friend.
-        FoundInaccessibleBase = true;
+        // FIXME: Check if the current function/class is a friend.
+        if (CurrentClassDecl != Element->Class)
+          FoundInaccessibleBase = true;
         break;
       case AS_protected:  
         // FIXME: Implement