blob: af8149ea19430768687b7a9ac16b13b43ef4fd49 [file] [log] [blame]
Daniel Dunbar4fcfde42009-11-08 01:45:36 +00001// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s
2// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
3// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s
4// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
Fariborz Jahanian93034ca2009-10-16 19:20:59 +00005// RUN: true
6
7extern "C" int printf(...);
Fariborz Jahanian3759a032009-10-19 19:18:20 +00008extern "C" void exit(int);
Fariborz Jahanian93034ca2009-10-16 19:20:59 +00009
10struct A {
11 A (const A&) { printf("A::A(const A&)\n"); }
12 A() {};
13};
14
15struct B : public A {
16 B() {};
17};
18
19struct C : public B {
20 C() {};
21};
22
23struct X {
24 operator B&() {printf("X::operator B&()\n"); return b; }
25 operator C&() {printf("X::operator C&()\n"); return c; }
26 X (const X&) { printf("X::X(const X&)\n"); }
27 X () { printf("X::X()\n"); }
28 B b;
29 C c;
30};
31
32void f(A) {
33 printf("f(A)\n");
34}
35
36
37void func(X x)
38{
39 f (x);
40}
41
42int main()
43{
44 X x;
45 func(x);
46}
47
Fariborz Jahanian3759a032009-10-19 19:18:20 +000048struct Base;
49
50struct Root {
51 operator Base&() { exit(1); }
52};
53
54struct Derived;
55
56struct Base : Root {
57 Base(const Base&) { printf("Base::(const Base&)\n"); }
58 Base() { printf("Base::Base()\n"); }
59 operator Derived&() { exit(1); }
60};
61
62struct Derived : Base {
63};
64
65void foo(Base) {}
66
67void test(Derived bb)
68{
69 // CHECK-LP64-NOT: call __ZN4BasecvR7DerivedEv
70 // CHECK-LP32-NOT: call L__ZN4BasecvR7DerivedEv
71 foo(bb);
72}
Fariborz Jahanian93034ca2009-10-16 19:20:59 +000073// CHECK-LP64: call __ZN1XcvR1BEv
74// CHECK-LP64: call __ZN1AC1ERKS_
75
76// CHECK-LP32: call L__ZN1XcvR1BEv
77// CHECK-LP32: call L__ZN1AC1ERKS_
Fariborz Jahanian3759a032009-10-19 19:18:20 +000078
79