aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2010-07-23 19:25:41 +0000
committerEli Friedman <eli.friedman@gmail.com>2010-07-23 19:25:41 +0000
commit0fab8cd9bd9093ce16b6ce64a152d861ba408652 (patch)
tree64420d3982481fd50f759842f913558f12fe81bd
parent320198303df7c16950d83ae79c3f702b84badcf7 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109257 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaCXXCast.cpp2
-rw-r--r--test/SemaCXX/access-member-pointer.cpp11
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/Sema/SemaCXXCast.cpp b/lib/Sema/SemaCXXCast.cpp
index b8e27e7b72..787bd00ac8 100644
--- a/lib/Sema/SemaCXXCast.cpp
+++ b/lib/Sema/SemaCXXCast.cpp
@@ -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;
diff --git a/test/SemaCXX/access-member-pointer.cpp b/test/SemaCXX/access-member-pointer.cpp
new file mode 100644
index 0000000000..676eb10dcd
--- /dev/null
+++ b/test/SemaCXX/access-member-pointer.cpp
@@ -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'}}
+}