Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s |
Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 2 | // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s |
Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 3 | // RUN: %clang_cc1 -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s |
Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 4 | // RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s |
Fariborz Jahanian | 93034ca | 2009-10-16 19:20:59 +0000 | [diff] [blame] | 5 | |
| 6 | extern "C" int printf(...); |
Fariborz Jahanian | 3759a03 | 2009-10-19 19:18:20 +0000 | [diff] [blame] | 7 | extern "C" void exit(int); |
Fariborz Jahanian | 93034ca | 2009-10-16 19:20:59 +0000 | [diff] [blame] | 8 | |
| 9 | struct A { |
Douglas Gregor | 2f59979 | 2010-04-02 18:24:57 +0000 | [diff] [blame] | 10 | A (const A&) { printf("A::A(const A&)\n"); } |
| 11 | A() {}; |
| 12 | ~A() { printf("A::~A()\n"); } |
Fariborz Jahanian | 93034ca | 2009-10-16 19:20:59 +0000 | [diff] [blame] | 13 | }; |
| 14 | |
| 15 | struct B : public A { |
| 16 | B() {}; |
Douglas Gregor | 2f59979 | 2010-04-02 18:24:57 +0000 | [diff] [blame] | 17 | B(const B& Other) : A(Other) { printf("B::B(const B&)\n"); } |
| 18 | ~B() { printf("B::~B()\n"); } |
| 19 | }; |
Fariborz Jahanian | 93034ca | 2009-10-16 19:20:59 +0000 | [diff] [blame] | 20 | |
| 21 | struct C : public B { |
| 22 | C() {}; |
Douglas Gregor | 2f59979 | 2010-04-02 18:24:57 +0000 | [diff] [blame] | 23 | C(const C& Other) : B(Other) { printf("C::C(const C&)\n"); } |
| 24 | ~C() { printf("C::~C()\n"); } |
Fariborz Jahanian | 93034ca | 2009-10-16 19:20:59 +0000 | [diff] [blame] | 25 | }; |
| 26 | |
| 27 | struct X { |
| 28 | operator B&() {printf("X::operator B&()\n"); return b; } |
| 29 | operator C&() {printf("X::operator C&()\n"); return c; } |
| 30 | X (const X&) { printf("X::X(const X&)\n"); } |
| 31 | X () { printf("X::X()\n"); } |
Douglas Gregor | 2f59979 | 2010-04-02 18:24:57 +0000 | [diff] [blame] | 32 | ~X () { printf("X::~X()\n"); } |
Fariborz Jahanian | 93034ca | 2009-10-16 19:20:59 +0000 | [diff] [blame] | 33 | B b; |
| 34 | C c; |
| 35 | }; |
| 36 | |
| 37 | void f(A) { |
| 38 | printf("f(A)\n"); |
| 39 | } |
| 40 | |
| 41 | |
| 42 | void func(X x) |
| 43 | { |
| 44 | f (x); |
| 45 | } |
| 46 | |
| 47 | int main() |
| 48 | { |
| 49 | X x; |
| 50 | func(x); |
| 51 | } |
| 52 | |
Fariborz Jahanian | 3759a03 | 2009-10-19 19:18:20 +0000 | [diff] [blame] | 53 | struct Base; |
| 54 | |
| 55 | struct Root { |
| 56 | operator Base&() { exit(1); } |
| 57 | }; |
| 58 | |
| 59 | struct Derived; |
| 60 | |
| 61 | struct Base : Root { |
| 62 | Base(const Base&) { printf("Base::(const Base&)\n"); } |
| 63 | Base() { printf("Base::Base()\n"); } |
| 64 | operator Derived&() { exit(1); } |
| 65 | }; |
| 66 | |
| 67 | struct Derived : Base { |
| 68 | }; |
| 69 | |
| 70 | void foo(Base) {} |
| 71 | |
| 72 | void test(Derived bb) |
| 73 | { |
Sean Callanan | 3b29901 | 2009-12-18 00:04:09 +0000 | [diff] [blame] | 74 | // CHECK-LP64-NOT: callq __ZN4BasecvR7DerivedEv |
| 75 | // CHECK-LP32-NOT: callq L__ZN4BasecvR7DerivedEv |
Fariborz Jahanian | 3759a03 | 2009-10-19 19:18:20 +0000 | [diff] [blame] | 76 | foo(bb); |
| 77 | } |
Sean Callanan | 3b29901 | 2009-12-18 00:04:09 +0000 | [diff] [blame] | 78 | // CHECK-LP64: callq __ZN1XcvR1BEv |
| 79 | // CHECK-LP64: callq __ZN1AC1ERKS_ |
Fariborz Jahanian | 93034ca | 2009-10-16 19:20:59 +0000 | [diff] [blame] | 80 | |
| 81 | // CHECK-LP32: call L__ZN1XcvR1BEv |
| 82 | // CHECK-LP32: call L__ZN1AC1ERKS_ |
Fariborz Jahanian | 3759a03 | 2009-10-19 19:18:20 +0000 | [diff] [blame] | 83 | |
| 84 | |