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