[PATCH] D11828: [MSVC] Crash fix: assigning of overloaded member function pointer caused assertion
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 7 05:04:46 PDT 2015
ABataev created this revision.
ABataev added reviewers: rnk, majnemer, rsmith.
ABataev added a subscriber: cfe-commits.
Currently code doe not handling typedefs correctly. Also original class was not marked with inheritance attribute and it causes a crash on codegen.
http://reviews.llvm.org/D11828
Files:
lib/Sema/SemaCast.cpp
lib/Sema/SemaType.cpp
test/CodeGenCXX/microsoft-abi-member-pointers.cpp
Index: lib/Sema/SemaType.cpp
===================================================================
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -6476,7 +6476,7 @@
// We lock in the inheritance model once somebody has asked us to ensure
// that a pointer-to-member type is complete.
if (Context.getTargetInfo().getCXXABI().isMicrosoft()) {
- if (const MemberPointerType *MPTy = T->getAs<MemberPointerType>()) {
+ if (auto *MPTy = T.getCanonicalType()->getAs<MemberPointerType>()) {
if (!MPTy->getClass()->isDependentType()) {
RequireCompleteType(Loc, QualType(MPTy->getClass(), 0), 0);
assignInheritanceModel(*this, MPTy->getMostRecentCXXRecordDecl());
Index: lib/Sema/SemaCast.cpp
===================================================================
--- lib/Sema/SemaCast.cpp
+++ lib/Sema/SemaCast.cpp
@@ -1396,7 +1396,8 @@
if (!SrcMemPtr) {
msg = diag::err_bad_static_cast_member_pointer_nonmp;
return TC_NotApplicable;
- }
+ } else if (Self.Context.getTargetInfo().getCXXABI().isMicrosoft())
+ Self.RequireCompleteType(OpRange.getBegin(), SrcType, 0);
// T == T, modulo cv
if (!Self.Context.hasSameUnqualifiedType(SrcMemPtr->getPointeeType(),
Index: test/CodeGenCXX/microsoft-abi-member-pointers.cpp
===================================================================
--- test/CodeGenCXX/microsoft-abi-member-pointers.cpp
+++ test/CodeGenCXX/microsoft-abi-member-pointers.cpp
@@ -729,3 +729,20 @@
// CHECK: @"\01??_9C at pr23878@@$BA at AE" to i8*), i32 0, i32 4
DMemPtrTy get_memptr() { return &D::f; }
}
+
+class C {};
+
+typedef void (C::*f)();
+
+class CA : public C {
+public:
+ void OnHelp(void);
+ int OnHelp(int);
+};
+
+// CHECK-LABEL: foo_fun
+void foo_fun() {
+ // CHECK: store i8* bitcast (void (%class.CA*)* @"\01?OnHelp at CA@@QAEXXZ" to i8*), i8**
+ f func = (f)&CA::OnHelp;
+}
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11828.31504.patch
Type: text/x-patch
Size: 1884 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150807/6a9ab4b7/attachment.bin>
More information about the cfe-commits
mailing list