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) {
// 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
}
}
+
+namespace T5 {
+ class A {};
+
+ class B : private A {
+ void f(B *b) {
+ A *a = b;
+ }
+ };
+}
+
+namespace T6 {
+ class C;
+
+ class A {};
+
+ class B : private A { // expected-note {{'private' inheritance specifier here}}
+ void f(C* c);
+ };
+
+ class C : public B {
+ void f(C *c) {
+ A* a = c; // expected-error {{conversion from 'class T6::C' to inaccessible base class 'class T6::A'}} \
+ expected-error {{incompatible type initializing 'class T6::C *', expected 'class T6::A *'}}
+ }
+ };
+
+ void B::f(C *c) {
+ A *a = c;
+ }
+}