]> granicus.if.org Git - clang/commitdiff
Fix for PR7694: make sure to pass in a RecordType to CheckBaseClassAccess;
authorEli Friedman <eli.friedman@gmail.com>
Fri, 23 Jul 2010 19:25:41 +0000 (19:25 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Fri, 23 Jul 2010 19:25:41 +0000 (19:25 +0000)
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

lib/Sema/SemaCXXCast.cpp
test/SemaCXX/access-member-pointer.cpp [new file with mode: 0644]

index b8e27e7b7285a56e87ca18eb37b29a2e4049087d..787bd00ac818243a0e48af3597ebb988e8d58f6e 100644 (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;
diff --git a/test/SemaCXX/access-member-pointer.cpp b/test/SemaCXX/access-member-pointer.cpp
new file mode 100644 (file)
index 0000000..676eb10
--- /dev/null
@@ -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'}}
+}