summaryrefslogtreecommitdiff
path: root/test/CodeGenCXX
diff options
context:
space:
mode:
Diffstat (limited to 'test/CodeGenCXX')
-rw-r--r--test/CodeGenCXX/array-construction.cpp3
-rw-r--r--test/CodeGenCXX/ptr-to-datamember.cpp13
-rw-r--r--test/CodeGenCXX/ptr-to-member-function.cpp18
-rw-r--r--test/CodeGenCXX/virt.cpp112
4 files changed, 98 insertions, 48 deletions
diff --git a/test/CodeGenCXX/array-construction.cpp b/test/CodeGenCXX/array-construction.cpp
index b444221533d31..5b6bc2e5b5114 100644
--- a/test/CodeGenCXX/array-construction.cpp
+++ b/test/CodeGenCXX/array-construction.cpp
@@ -17,12 +17,9 @@ public:
int i;
float f;
-/**
- NYI
~xpto() {
printf("xpto::~xpto()\n");
}
-*/
};
int main() {
diff --git a/test/CodeGenCXX/ptr-to-datamember.cpp b/test/CodeGenCXX/ptr-to-datamember.cpp
index a7b4cc2f7afb9..ffaef32a13c9c 100644
--- a/test/CodeGenCXX/ptr-to-datamember.cpp
+++ b/test/CodeGenCXX/ptr-to-datamember.cpp
@@ -32,6 +32,15 @@ public:
F Af;
};
+template <typename T> struct TT {
+ int T::t::*pti;
+};
+
+struct I {
+ typedef I t;
+ int x;
+};
+
void pr(const F& b) {
printf(" %d %f\n", b.iF, b.fF);
}
@@ -69,9 +78,12 @@ void test_aggr_pdata_1(A* pa) {
int main()
{
A a1;
+ TT<I> tt;
+ I i;
int A::* pa = &A::Ai;
float A::* pf = &A::f;
double A::* pd = &A::d;
+ tt.pti = &I::x;
printf("%d %d %d\n", &A::Ai, &A::f, &A::d);
printf("%d\n", &A::B::iB);
printf("%d\n", &A::B1::iB1);
@@ -81,6 +93,7 @@ int main()
printf("%d\n", &A::B::V::iV);
printf("%d\n", &A::B1::V::iV);
printf("%d, %f, %f \n", a1.*pa, a1.*pf, a1.*pd);
+ printf("%d\n", i.*tt.pti);
test_aggr_pdata(a1);
test_aggr_pdata_1(&a1);
}
diff --git a/test/CodeGenCXX/ptr-to-member-function.cpp b/test/CodeGenCXX/ptr-to-member-function.cpp
index 1e396e976575d..15019081c0620 100644
--- a/test/CodeGenCXX/ptr-to-member-function.cpp
+++ b/test/CodeGenCXX/ptr-to-member-function.cpp
@@ -9,8 +9,14 @@ extern "C" int printf(...);
struct A {
int Ai;
+bool foo(int* arg) const;
};
+bool A::foo(int* arg) const {
+ printf("A::foo(%d)\n", *arg);
+ return true;
+}
+
struct B : public A {
void bf() { printf("B::bf called\n"); }
};
@@ -40,10 +46,22 @@ void test2(X x)
g(x);
}
+struct B1 {
+ bool (A::*pmf)(int*) const;
+
+ B1(int i) : pmf(&A::foo), im(i) {
+ ((A*)this->*pmf)(&im);
+ }
+
+ int im;
+};
+
int main()
{
X x;
test2(x);
+ B1 b = B1(1);
+ B1 c = B1(2);
}
// CHECK-LP64: call __ZN1XcvM1BFvvEEv
diff --git a/test/CodeGenCXX/virt.cpp b/test/CodeGenCXX/virt.cpp
index 7911940c6dabd..193a96ddd5897 100644
--- a/test/CodeGenCXX/virt.cpp
+++ b/test/CodeGenCXX/virt.cpp
@@ -48,9 +48,11 @@ public:
void F::foo() { }
int j;
+void *vp;
void test2() {
F f;
static int sz = (char *)(&f.f) - (char *)(&f);
+ vp = &sz;
j = sz;
// FIXME: These should result in a frontend constant a la fold, no run time
// initializer
@@ -91,50 +93,6 @@ int main() {
// CHECK-LP64: movl $1, 12(%rax)
// CHECK-LP64: movl $2, 8(%rax)
-// FIXME: This is the wrong thunk, but until these issues are fixed, better
-// than nothing.
-// CHECK-LP64: __ZTcvn16_n72_v16_n32_N8test16_D4foo1Ev:
-// CHECK-LP64-NEXT:Leh_func_begin43:
-// CHECK-LP64-NEXT: subq $24, %rsp
-// CHECK-LP64-NEXT:Llabel43:
-// CHECK-LP64-NEXT: movq %rdi, %rax
-// CHECK-LP64-NEXT: movq %rax, 8(%rsp)
-// CHECK-LP64-NEXT: movq 8(%rsp), %rax
-// CHECK-LP64-NEXT: movq %rax, %rcx
-// CHECK-LP64-NEXT: movabsq $-16, %rdx
-// CHECK-LP64-NEXT: addq %rdx, %rcx
-// CHECK-LP64-NEXT: movq -16(%rax), %rax
-// CHECK-LP64-NEXT: movq -72(%rax), %rax
-// CHECK-LP64-NEXT: addq %rax, %rcx
-// CHECK-LP64-NEXT: movq %rcx, %rax
-// CHECK-LP64-NEXT: movq %rax, %rdi
-// CHECK-LP64-NEXT: call __ZTch0_v16_n32_N8test16_D4foo1Ev
-// CHECK-LP64-NEXT: movq %rax, 16(%rsp)
-// CHECK-LP64-NEXT: movq 16(%rsp), %rax
-// CHECK-LP64-NEXT: addq $24, %rsp
-// CHECK-LP64-NEXT: ret
-
-// CHECK-LP64: __ZTch0_v16_n32_N8test16_D4foo1Ev:
-// CHECK-LP64-NEXT:Leh_func_begin44:
-// CHECK-LP64-NEXT: subq $24, %rsp
-// CHECK-LP64-NEXT:Llabel44:
-// CHECK-LP64-NEXT: movq %rdi, %rax
-// CHECK-LP64-NEXT: movq %rax, 8(%rsp)
-// CHECK-LP64-NEXT: movq 8(%rsp), %rax
-// CHECK-LP64-NEXT: movq %rax, %rdi
-// CHECK-LP64-NEXT: call __ZN8test16_D4foo1Ev
-// CHECK-LP64-NEXT: movq %rax, %rcx
-// CHECK-LP64-NEXT: movabsq $16, %rdx
-// CHECK-LP64-NEXT: addq %rdx, %rcx
-// CHECK-LP64-NEXT: movq 16(%rax), %rax
-// CHECK-LP64-NEXT: movq -32(%rax), %rax
-// CHECK-LP64-NEXT: addq %rax, %rcx
-// CHECK-LP64-NEXT: movq %rcx, %rax
-// CHECK-LP64-NEXT: movq %rax, 16(%rsp)
-// CHECK-LP64-NEXT: movq 16(%rsp), %rax
-// CHECK-LP64-NEXT: addq $24, %rsp
-// CHECK-LP64-NEXT: ret
-
struct test12_A {
virtual void foo0() { }
virtual void foo();
@@ -207,6 +165,7 @@ void test12_foo() {
// CHECK-LPOPT64-NEXT: movq _test12_pa(%rip), %rdi
// CHECK-LPOPT64-NEXT: call __ZN8test12_A3fooEv
+
struct test6_B2 { virtual void funcB2(); char b[1000]; };
struct test6_B1 : virtual test6_B2 { virtual void funcB1(); };
@@ -1003,9 +962,12 @@ virtual void foo_B2() { }
};
struct test16_D : test16_NV1, virtual test16_B2 {
- virtual test16_D *foo1() { return 0; }
+ virtual void bar();
+ virtual test16_D *foo1();
};
+void test16_D::bar() { }
+
// CHECK-LP64: __ZTV8test16_D:
// CHECK-LP64-NEXT: .quad 32
// CHECK-LP64-NEXT: .quad 16
@@ -1013,6 +975,7 @@ struct test16_D : test16_NV1, virtual test16_B2 {
// CHECK-LP64-NEXT: .quad __ZTI8test16_D
// CHECK-LP64-NEXT: .quad __ZN10test16_NV16fooNV1Ev
// CHECK-LP64-NEXT: .quad __ZN10test16_NV17foo_NV1Ev
+// CHECK-LP64-NEXT: .quad __ZN8test16_D3barEv
// CHECK-LP64-NEXT: .quad __ZN8test16_D4foo1Ev
// CHECK-LP64-NEXT: .space 8
// CHECK-LP64-NEXT: .space 8
@@ -1056,6 +1019,7 @@ struct test16_D : test16_NV1, virtual test16_B2 {
// CHECK-LP32-NEXT: .long __ZTI8test16_D
// CHECK-LP32-NEXT: .long __ZN10test16_NV16fooNV1Ev
// CHECK-LP32-NEXT: .long __ZN10test16_NV17foo_NV1Ev
+// CHECK-LP32-NEXT: .long __ZN8test16_D3barEv
// CHECK-LP32-NEXT: .long __ZN8test16_D4foo1Ev
// CHECK-LP32-NEXT: .space 4
// CHECK-LP32-NEXT: .space 4
@@ -1093,6 +1057,37 @@ struct test16_D : test16_NV1, virtual test16_B2 {
// CHECK-LP32-NEXT: .long __ZN10test16_NV28foo_NV2bEv
+// FIXME: This is the wrong thunk, but until these issues are fixed, better
+// than nothing.
+// CHECK-LPOPT64: __ZTcvn16_n72_v16_n32_N8test16_D4foo1Ev:
+// CHECK-LPOPT64-NEXT:Leh_func_begin
+// CHECK-LPOPT64-NEXT: subq $8, %rsp
+// CHECK-LPOPT64-NEXT:Llabel
+// CHECK-LPOPT64-NEXT: movq -16(%rdi), %rax
+// CHECK-LPOPT64-NEXT: movq -72(%rax), %rax
+// CHECK-LPOPT64-NEXT: leaq -16(%rax,%rdi), %rdi
+// FIXME: We want a tail call here
+// CHECK-LPOPT64-NEXT: call __ZTch0_v16_n32_N8test16_D4foo1Ev
+// CHECK-LPOPT64-NEXT: addq $8, %rsp
+// CHECK-LPOPT64-NEXT: ret
+
+// CHECK-LPOPT64: __ZTch0_v16_n32_N8test16_D4foo1Ev:
+// CHECK-LPOPT64-NEXT:Leh_func_begin
+// CHECK-LPOPT64-NEXT: subq $8, %rsp
+// CHECK-LPOPT64-NEXT:Llabel
+// CHECK-LPOPT64-NEXT: call __ZN8test16_D4foo1Ev
+// CHECK-LPOPT64-NEXT: testq %rax, %rax
+// CHECK-LPOPT64-NEXT: je LBB102_2
+// CHECK-LPOPT64-NEXT: movq 16(%rax), %rcx
+// CHECK-LPOPT64-NEXT: movq -32(%rcx), %rcx
+// CHECK-LPOPT64-NEXT: leaq 16(%rcx,%rax), %rax
+// CHECK-LPOPT64-NEXT: addq $8, %rsp
+// CHECK-LPOPT64-NEXT: ret
+// CHECK-LPOPT64-NEXT:LBB102_2:
+// CHECK-LPOPT64-NEXT: addq $8, %rsp
+// CHECK-LPOPT64-NEXT: ret
+
+
class test17_B1 {
virtual void foo() = 0;
virtual void bar() { }
@@ -1237,6 +1232,33 @@ struct test19_D : virtual test19_B4 {
// CHECK-LP64-NEXT .quad __ZN9test19_B43fB4Ev
+class test20_V {
+ virtual void foo1();
+};
+class test20_V1 {
+ virtual void foo2();
+};
+class test20_B : virtual test20_V {
+} b;
+class test20_B1 : virtual test20_V1 {
+};
+class test20_D : public test20_B, public test20_B1 {
+} d;
+
+// CHECK-LP64: __ZTV8test20_D:
+// CHECK-LP64-NEXT: .quad 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .quad __ZTI8test20_D
+// CHECK-LP64-NEXT: .quad __ZN8test20_V4foo1Ev
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .quad 18446744073709551608
+// CHECK-LP64-NEXT: .quad __ZTI8test20_D
+// CHECK-LP64-NEXT: .quad __ZN9test20_V14foo2Ev
+
+
// CHECK-LP64: __ZTV1B:
// CHECK-LP64-NEXT: .space 8