summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-03-22 16:44:39 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-03-22 16:44:39 +0000
commitaf382652b26fe92b2269149affb64026fc214654 (patch)
treeacf9e332186f000b15d7bbbd58cc85bac02f8447
parent09804e275f78eec9a3bd42220106d84282a89ce6 (diff)
downloadbcm5719-llvm-af382652b26fe92b2269149affb64026fc214654.tar.gz
bcm5719-llvm-af382652b26fe92b2269149affb64026fc214654.zip
[MS ABI] Assign an inheritance model for the dest of a member pointer upcast
While we correctly assigned an inheritance model for the source of a member pointer upcast, we did not do so for the destination. This fixes PR27030. llvm-svn: 264065
-rw-r--r--clang/lib/Sema/SemaCast.cpp4
-rw-r--r--clang/test/CodeGenCXX/pr27030.cpp17
2 files changed, 20 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index 7207d04158a..4a7699b22e2 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/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/clang/test/CodeGenCXX/pr27030.cpp b/clang/test/CodeGenCXX/pr27030.cpp
new file mode 100644
index 00000000000..7a582d242ee
--- /dev/null
+++ b/clang/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]], {{.*}} ]
OpenPOWER on IntegriCloud