aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGenCXX
diff options
context:
space:
mode:
authorRoman Divacky <rdivacky@FreeBSD.org>2009-11-04 15:04:32 +0000
committerRoman Divacky <rdivacky@FreeBSD.org>2009-11-04 15:04:32 +0000
commit51fb8b013e7734b795139f49d3b1f77c539be20a (patch)
tree59e0e47a9831dcf0e21e547927c8ebb7e113bfd1 /test/CodeGenCXX
parent73490b890977362d28dd6326843a1ecae413921d (diff)
downloadsrc-51fb8b013e7734b795139f49d3b1f77c539be20a.tar.gz
src-51fb8b013e7734b795139f49d3b1f77c539be20a.zip
Update clang to r86025.vendor/clang/clang-r86025
Notes
Notes: svn path=/vendor/clang/dist/; revision=198893 svn path=/vendor/clang/clang-r86025/; revision=198895; tag=vendor/clang/clang-r86025
Diffstat (limited to 'test/CodeGenCXX')
-rw-r--r--test/CodeGenCXX/array-construction.cpp40
-rw-r--r--test/CodeGenCXX/ptr-to-datamember.cpp16
-rw-r--r--test/CodeGenCXX/ptr-to-member-function.cpp53
-rw-r--r--test/CodeGenCXX/temporaries.cpp6
-rw-r--r--test/CodeGenCXX/virt.cpp208
5 files changed, 312 insertions, 11 deletions
diff --git a/test/CodeGenCXX/array-construction.cpp b/test/CodeGenCXX/array-construction.cpp
new file mode 100644
index 000000000000..b444221533d3
--- /dev/null
+++ b/test/CodeGenCXX/array-construction.cpp
@@ -0,0 +1,40 @@
+// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s &&
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s &&
+// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s &&
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s &&
+// RUN: true
+
+extern "C" int printf(...);
+
+static int count;
+static float fcount;
+
+class xpto {
+public:
+ xpto() : i(count++), f(fcount++) {
+ printf("xpto::xpto()\n");
+ }
+ int i;
+ float f;
+
+/**
+ NYI
+ ~xpto() {
+ printf("xpto::~xpto()\n");
+ }
+*/
+};
+
+int main() {
+ xpto array[2][3][4];
+ for (int h = 0; h < 2; h++)
+ for (int i = 0; i < 3; i++)
+ for (int j = 0; j < 4; j++)
+ printf("array[%d][%d][%d] = {%d, %f}\n",
+ h, i, j, array[h][i][j].i, array[h][i][j].f);
+}
+
+// CHECK-LP64: call __ZN4xptoC1Ev
+
+// CHECK-LP32: call L__ZN4xptoC1Ev
+
diff --git a/test/CodeGenCXX/ptr-to-datamember.cpp b/test/CodeGenCXX/ptr-to-datamember.cpp
index eee03c060f91..a7b4cc2f7afb 100644
--- a/test/CodeGenCXX/ptr-to-datamember.cpp
+++ b/test/CodeGenCXX/ptr-to-datamember.cpp
@@ -51,6 +51,21 @@ void test_aggr_pdata(A& a1) {
pr(a1.*af);
}
+void test_aggr_pdata_1(A* pa) {
+ F A::* af = &A::Af;
+ pr(pa->*af);
+
+ (pa->*af).iF = 100;
+ (pa->*af).fF = 200.00;
+ printf(" %d %f\n", (pa->*af).iF, (pa->*af).fF);
+ pr(pa->*af);
+
+ (pa->*af).iF++;
+ (pa->*af).fF--;
+ --(pa->*af).fF;
+ pr(pa->*af);
+}
+
int main()
{
A a1;
@@ -67,4 +82,5 @@ int main()
printf("%d\n", &A::B1::V::iV);
printf("%d, %f, %f \n", a1.*pa, a1.*pf, a1.*pd);
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
new file mode 100644
index 000000000000..1e396e976575
--- /dev/null
+++ b/test/CodeGenCXX/ptr-to-member-function.cpp
@@ -0,0 +1,53 @@
+// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s &&
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s &&
+// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s &&
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s &&
+// RUN: true
+// 13.3.3.2 Ranking implicit conversion sequences
+
+extern "C" int printf(...);
+
+struct A {
+int Ai;
+};
+
+struct B : public A {
+ void bf() { printf("B::bf called\n"); }
+};
+
+struct C : public B { };
+
+// conversion of B::* to C::* is better than conversion of A::* to C::*
+typedef void (A::*pmfa)();
+typedef void (B::*pmfb)();
+typedef void (C::*pmfc)();
+
+struct X {
+ operator pmfa();
+ operator pmfb() {
+ return &B::bf;
+ }
+};
+
+
+void g(pmfc pm) {
+ C c;
+ (c.*pm)();
+}
+
+void test2(X x)
+{
+ g(x);
+}
+
+int main()
+{
+ X x;
+ test2(x);
+}
+
+// CHECK-LP64: call __ZN1XcvM1BFvvEEv
+// CHECK-LP64: call __Z1gM1CFvvE
+
+// CHECK-LP32: call L__ZN1XcvM1BFvvEEv
+// CHECK-LP32: call __Z1gM1CFvvE
diff --git a/test/CodeGenCXX/temporaries.cpp b/test/CodeGenCXX/temporaries.cpp
index d622193f5986..e9ed0f7690bc 100644
--- a/test/CodeGenCXX/temporaries.cpp
+++ b/test/CodeGenCXX/temporaries.cpp
@@ -53,9 +53,9 @@ struct D {
};
void f4() {
- // CHECK call void @_ZN1DC1Ev
- // CHECK call void @_ZN1DD1Ev
- // CHECK call void @_ZN1DD1Ev
+ // CHECK: call void @_ZN1DC1Ev
+ // CHECK: call void @_ZN1DD1Ev
+ // CHECK: call void @_ZN1DD1Ev
D()();
}
diff --git a/test/CodeGenCXX/virt.cpp b/test/CodeGenCXX/virt.cpp
index 21fecac11e7b..7911940c6dab 100644
--- a/test/CodeGenCXX/virt.cpp
+++ b/test/CodeGenCXX/virt.cpp
@@ -91,6 +91,50 @@ 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();
@@ -306,10 +350,10 @@ struct test5_D : virtual test5_B1, virtual test5_B21, virtual test5_B31 {
// CHECK-LP32-NEXT: .long __ZN9test5_B227funcB22Ev
// CHECK-LP32-NEXT: .long __ZN9test5_B217funcB21Ev
// CHECK-LP32-NEXT: .space 4
-// CHECK-LP32: .long 8
-// CHECK-LP32 .space 4
-// CHECK-LP32 .space 4 FIXME
-// CHECK-LP32: .long 4
+// CHECK-LP32-NEXT: .long 8
+// CHECK-LP32-NEXT: .space 4
+// CHECK-LP32-NEXT: .space 4
+// CHECK-LP32-NEXT: .long 4
// CHECK-LP32-NEXT: .space 4
// CHECK-LP32-NEXT: .space 4
// CHECK-LP32-NEXT: .long 4294967288
@@ -358,10 +402,10 @@ struct test5_D : virtual test5_B1, virtual test5_B21, virtual test5_B31 {
// CHECK-LP64-NEXT: .quad __ZN9test5_B227funcB22Ev
// CHECK-LP64-NEXT: .quad __ZN9test5_B217funcB21Ev
// CHECK-LP64-NEXT: .space 8
-// CHECK-LP64: .quad 16
-// CHECK-LP64 .space 8
-// CHECK-LP64 .space 8
-// CHECK-LP64: .quad 8
+// CHECK-LP64-NEXT: .quad 16
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .quad 8
// CHECK-LP64-NEXT: .space 8
// CHECK-LP64-NEXT: .space 8
// CHECK-LP64-NEXT: .quad 18446744073709551600
@@ -1049,6 +1093,151 @@ struct test16_D : test16_NV1, virtual test16_B2 {
// CHECK-LP32-NEXT: .long __ZN10test16_NV28foo_NV2bEv
+class test17_B1 {
+ virtual void foo() = 0;
+ virtual void bar() { }
+};
+
+class test17_B2 : public test17_B1 {
+ void foo() { }
+ virtual void bar() = 0;
+};
+
+class test17_D : public test17_B2 {
+ void bar() { }
+};
+
+
+// CHECK-LP64:__ZTV8test17_D:
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .quad __ZTI8test17_D
+// CHECK-LP64-NEXT: .quad __ZN9test17_B23fooEv
+// CHECK-LP64-NEXT: .quad __ZN8test17_D3barEv
+
+// CHECK-LP64:__ZTV9test17_B2:
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .quad __ZTI9test17_B2
+// CHECK-LP64-NEXT: .quad __ZN9test17_B23fooEv
+// CHECK-LP64-NEXT: .quad ___cxa_pure_virtual
+
+// CHECK-LP64:__ZTV9test17_B1:
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .quad __ZTI9test17_B1
+// CHECK-LP64-NEXT: .quad ___cxa_pure_virtual
+// CHECK-LP64-NEXT: .quad __ZN9test17_B13barEv
+
+
+struct test18_NV1 {
+ virtual void fooNV1() { }
+virtual void foo_NV1() { }
+ int i;
+};
+
+struct test18_NV2 {
+ virtual test18_NV2& foo1() { return *this; }
+virtual void foo_NV2() { }
+virtual void foo_NV2b() { }
+ int i;
+};
+
+struct test18_B : public test18_NV1, test18_NV2 {
+ virtual test18_B& foo1() { return *this; }
+ virtual test18_B *foo2() { return 0; }
+ virtual test18_B *foo3() { return 0; }
+virtual void foo_B() { }
+ int i;
+};
+
+struct test18_B2 : test18_NV1, virtual test18_B {
+ virtual test18_B2& foo1() { return *this; }
+ virtual test18_B2 *foo2() { return 0; }
+virtual void foo_B2() { }
+ int i;
+};
+
+struct test18_D : test18_NV1, virtual test18_B2 {
+ virtual test18_D& foo1() { return *this; }
+};
+
+
+struct test19_VB1 { };
+struct test19_B1 : public virtual test19_VB1 {
+ virtual void fB1() { }
+ virtual void foB1B2() { }
+ virtual void foB1B3() { }
+ virtual void foB1B4() { }
+};
+
+struct test19_VB2 { };
+struct test19_B2: public test19_B1, public virtual test19_VB2 {
+ virtual void foB1B2() { }
+ virtual void foB1B3() { }
+ virtual void foB1B4() { }
+
+ virtual void fB2() { }
+ virtual void foB2B3() { }
+ virtual void foB2B4() { }
+};
+
+struct test19_VB3 { };
+struct test19_B3: virtual public test19_B2, public virtual test19_VB3 {
+ virtual void foB1B3() { }
+ virtual void foB1B4() { }
+
+ virtual void foB2B3() { }
+ virtual void foB2B4() { }
+
+ virtual void fB3() { }
+ virtual void foB3B4() { }
+};
+
+struct test19_VB4 { };
+struct test19_B4: public test19_B3, public virtual test19_VB4 {
+ virtual void foB1B4() { }
+
+ virtual void foB2B4() { }
+
+ virtual void foB3B4() { }
+
+ virtual void fB4() { }
+};
+
+struct test19_D : virtual test19_B4 {
+};
+
+
+// CHECK-LP64: __ZTV8test19_D:
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .quad __ZTI8test19_D
+// CHECK-LP64-NEXT .quad __ZN9test19_B13fB1Ev
+// CHECK-LP64-NEXT .quad __ZN9test19_B26foB1B2Ev
+// CHECK-LP64-NEXT .quad __ZN9test19_B36foB1B3Ev
+// CHECK-LP64-NEXT .quad __ZN9test19_B46foB1B4Ev
+// CHECK-LP64-NEXT .quad __ZN9test19_B23fB2Ev
+// CHECK-LP64-NEXT .quad __ZN9test19_B36foB2B3Ev
+// CHECK-LP64-NEXT .quad __ZN9test19_B46foB2B4Ev
+// CHECK-LP64-NEXT .quad __ZN9test19_B33fB3Ev
+// CHECK-LP64-NEXT .quad __ZN9test19_B46foB3B4Ev
+// CHECK-LP64-NEXT .quad __ZN9test19_B43fB4Ev
+
+
+
// CHECK-LP64: __ZTV1B:
// CHECK-LP64-NEXT: .space 8
// CHECK-LP64-NEXT: .quad __ZTI1B
@@ -1127,6 +1316,9 @@ struct test16_D : test16_NV1, virtual test16_B2 {
// CHECK-LP64-NEXT: .quad __ZN2D14bar4Ev
// CHECK-LP64-NEXT: .quad __ZN2D14bar5Ev
+test19_D d19;
+test18_D d18;
+test17_D d17;
test16_D d16;
test15_D d15;
test13_D d13;