blob: c1a0caa7584f521e6dffcb207ad02c9f68c228d5 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s
Daniel Dunbar4fcfde42009-11-08 01:45:36 +00002// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
Daniel Dunbara5728872009-12-15 20:14:24 +00003// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s
Daniel Dunbar4fcfde42009-11-08 01:45:36 +00004// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
Fariborz Jahanian93034ca2009-10-16 19:20:59 +00005
6extern "C" int printf(...);
Fariborz Jahanian3759a032009-10-19 19:18:20 +00007extern "C" void exit(int);
Fariborz Jahanian93034ca2009-10-16 19:20:59 +00008
9struct A {
10 A (const A&) { printf("A::A(const A&)\n"); }
11 A() {};
12};
13
14struct B : public A {
15 B() {};
16};
17
18struct C : public B {
19 C() {};
20};
21
22struct X {
23 operator B&() {printf("X::operator B&()\n"); return b; }
24 operator C&() {printf("X::operator C&()\n"); return c; }
25 X (const X&) { printf("X::X(const X&)\n"); }
26 X () { printf("X::X()\n"); }
27 B b;
28 C c;
29};
30
31void f(A) {
32 printf("f(A)\n");
33}
34
35
36void func(X x)
37{
38 f (x);
39}
40
41int main()
42{
43 X x;
44 func(x);
45}
46
Fariborz Jahanian3759a032009-10-19 19:18:20 +000047struct Base;
48
49struct Root {
50 operator Base&() { exit(1); }
51};
52
53struct Derived;
54
55struct Base : Root {
56 Base(const Base&) { printf("Base::(const Base&)\n"); }
57 Base() { printf("Base::Base()\n"); }
58 operator Derived&() { exit(1); }
59};
60
61struct Derived : Base {
62};
63
64void foo(Base) {}
65
66void test(Derived bb)
67{
Sean Callanan3b299012009-12-18 00:04:09 +000068 // CHECK-LP64-NOT: callq __ZN4BasecvR7DerivedEv
69 // CHECK-LP32-NOT: callq L__ZN4BasecvR7DerivedEv
Fariborz Jahanian3759a032009-10-19 19:18:20 +000070 foo(bb);
71}
Sean Callanan3b299012009-12-18 00:04:09 +000072// CHECK-LP64: callq __ZN1XcvR1BEv
73// CHECK-LP64: callq __ZN1AC1ERKS_
Fariborz Jahanian93034ca2009-10-16 19:20:59 +000074
75// CHECK-LP32: call L__ZN1XcvR1BEv
76// CHECK-LP32: call L__ZN1AC1ERKS_
Fariborz Jahanian3759a032009-10-19 19:18:20 +000077
78