]> granicus.if.org Git - clang/commitdiff
Some member pointer casting tests.
authorEli Friedman <eli.friedman@gmail.com>
Fri, 27 Nov 2009 04:56:40 +0000 (04:56 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Fri, 27 Nov 2009 04:56:40 +0000 (04:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89989 91177308-0d34-0410-b5e6-96231b3b80d8

test/CodeGenCXX/member-function-pointers.cpp
test/CodeGenCXX/member-pointer-cast.cpp [new file with mode: 0644]

index bba996206644d07799ff3954f3cda790f2b181f9..05bf39632517d92a5f43bac44423157625a5ce75 100644 (file)
@@ -34,6 +34,11 @@ void f() {
   // CHECK: [[ADJ:%[a-zA-Z0-9\.]+]] = add i64 {{.*}}, 16
   // CHECK: store i64 [[ADJ]], i64* getelementptr inbounds (%0* @pc, i32 0, i32 1)
   pc = pa;
+
+  // CHECK: store i64 {{.*}}, i64* getelementptr inbounds (%0* @pa, i32 0, i32 0)
+  // CHECK: [[ADJ:%[a-zA-Z0-9\.]+]] = sub i64 {{.*}}, 16
+  // CHECK: store i64 [[ADJ]], i64* getelementptr inbounds (%0* @pa, i32 0, i32 1)
+  pa = static_cast<void (A::*)()>(pc);
 }
 
 void f2() {
diff --git a/test/CodeGenCXX/member-pointer-cast.cpp b/test/CodeGenCXX/member-pointer-cast.cpp
new file mode 100644 (file)
index 0000000..7949968
--- /dev/null
@@ -0,0 +1,21 @@
+// RUN: clang-cc %s -emit-llvm -o - -triple=x86_64-apple-darwin9 | FileCheck %s
+
+struct A { int a; };
+struct B { int b; };
+struct C : B, A { };
+
+int A::*pa;
+int C::*pc;
+
+void f() {
+  // CHECK: store i64 -1, i64* @pa
+  pa = 0;
+
+  // CHECK: [[ADJ:%[a-zA-Z0-9\.]+]] = add i64 {{.*}}, 4
+  // CHECK: store i64 [[ADJ]], i64* @pc
+  pc = pa;
+
+  // CHECK: [[ADJ:%[a-zA-Z0-9\.]+]] = sub i64 {{.*}}, 4
+  // CHECK: store i64 [[ADJ]], i64* @pa
+  pa = static_cast<int A::*>(pc);
+}