diff --git a/lib/Sema/SemaCast.cpp b/lib/Sema/SemaCast.cpp index 7207d04158a9854c50891d94fd340e71c7c22c05..4a7699b22e22314f0135c2e3d7f8357a51190798 100644 --- a/lib/Sema/SemaCast.cpp +++ b/lib/Sema/SemaCast.cpp @@ -1402,8 +1402,10 @@ TryStaticMemberPointerUpcast(Sema &Self, ExprResult &SrcExpr, QualType SrcType, // Lock down the inheritance model right now in MS ABI, whether or not the // pointee types are the same. - if (Self.Context.getTargetInfo().getCXXABI().isMicrosoft()) + if (Self.Context.getTargetInfo().getCXXABI().isMicrosoft()) { (void)Self.isCompleteType(OpRange.getBegin(), SrcType); + (void)Self.isCompleteType(OpRange.getBegin(), DestType); + } // T == T, modulo cv if (!Self.Context.hasSameUnqualifiedType(SrcMemPtr->getPointeeType(), diff --git a/test/CodeGenCXX/pr27030.cpp b/test/CodeGenCXX/pr27030.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7a582d242ee8182eeb3982504ea8db12200a52b3 --- /dev/null +++ b/test/CodeGenCXX/pr27030.cpp @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -emit-llvm -triple=i386-pc-win32 %s -o - | FileCheck %s +struct A {}; +struct B : A {}; +extern "C" { +extern int B::*a; +void test1() { (int A::*)(a); } +} +// CHECK-LABEL: define void @test1( +// CHECK: %[[load:.*]] = load i32, i32* @a +// CHECK: %[[memptr_cmp:.*]] = icmp ne i32 %[[load]], -1 +// CHECK: br i1 %[[memptr_cmp]] + +// CHECK: %[[adj:.*]] = sub nsw i32 %[[load]], 0 +// CHECK: %[[nv_adj:.*]] = select i1 true, i32 %[[adj]], i32 0 +// CHECK: br label %memptr.converted + +// CHECK: %[[memptr_converted:.*]] = phi i32 [ -1, {{.*}} ], [ %[[nv_adj]], {{.*}} ]