Fix for PR7694: make sure to pass in a RecordType to CheckBaseClassAccess;

fixes crashes on both valid and invalid code.  The diagnostic here could
potentially be improved, but it's good enough as-is.

llvm-svn: 109257
This commit is contained in:
Eli Friedman 2010-07-23 19:25:41 +00:00
parent c51609a0b5
commit d4c75cddde
2 changed files with 12 additions and 1 deletions

View File

@ -900,7 +900,7 @@ TryStaticMemberPointerUpcast(Sema &Self, Expr *&SrcExpr, QualType SrcType,
}
if (!CStyle && Self.CheckBaseClassAccess(OpRange.getBegin(),
DestType, SrcType,
DestClass, SrcClass,
Paths.front(),
diag::err_upcast_to_inaccessible_base)) {
msg = 0;

View File

@ -0,0 +1,11 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// PR7694
class A { };
class B : private A { public: void foo(); }; // expected-note {{declared private here}}
void B::foo() {
(void)static_cast<void(A::*)()>(&B::foo);
}
void bar() {
(void)static_cast<void(A::*)()>(&B::foo); // expected-error {{cannot cast 'B' to its private base class 'A'}}
}