r239625 - [MS ABI] Lock-in the derived memptr rep. for base-to-derived conversions
David Majnemer
david.majnemer at gmail.com
Fri Jun 12 10:55:44 PDT 2015
Author: majnemer
Date: Fri Jun 12 12:55:44 2015
New Revision: 239625
URL: http://llvm.org/viewvc/llvm-project?rev=239625&view=rev
Log:
[MS ABI] Lock-in the derived memptr rep. for base-to-derived conversions
We would get this right in the case where an explicit cast was formed
but not when we were performing an implicit conversion.
This fixes PR23828.
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=239625&r1=239624&r2=239625&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Jun 12 12:55:44 2015
@@ -3290,10 +3290,10 @@ Sema::PerformImplicitConversion(Expr *Fr
// We may not have been able to figure out what this member pointer resolved
// to up until this exact point. Attempt to lock-in it's inheritance model.
- QualType FromType = From->getType();
- if (FromType->isMemberPointerType())
- if (Context.getTargetInfo().getCXXABI().isMicrosoft())
- RequireCompleteType(From->getExprLoc(), FromType, 0);
+ if (Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+ RequireCompleteType(From->getExprLoc(), From->getType(), 0);
+ RequireCompleteType(From->getExprLoc(), ToType, 0);
+ }
From = ImpCastExprToType(From, ToType, Kind, VK_RValue, &BasePath, CCK)
.get();
Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp?rev=239625&r1=239624&r2=239625&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp Fri Jun 12 12:55:44 2015
@@ -678,6 +678,17 @@ static_assert(sizeof(int A::*) == 12, ""
// CHECK-LABEL: define void @"\01?test at pr20007_pragma2@@YAXXZ"
}
+namespace pr23823 {
+struct Base { void Method(); };
+struct Child : Base {};
+void use(void (Child::*const &)());
+void f() { use(&Child::Method); }
+#pragma pointers_to_members(full_generality, virtual_inheritance)
+static_assert(sizeof(int Base::*) == 4, "");
+static_assert(sizeof(int Child::*) == 4, "");
+#pragma pointers_to_members(best_case)
+}
+
namespace pr19987 {
template <typename T>
struct S {
More information about the cfe-commits
mailing list