• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // REQUIRES: x86-registered-target,x86-64-registered-target
2 // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s
3 // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
4 // RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -S %s -o %t-32.s
5 // RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
6 
7 extern "C" int printf(...);
8 extern "C" void exit(int);
9 
10 struct A {
AA11   A (const A&) { printf("A::A(const A&)\n"); }
AA12   A() {};
~AA13   ~A() { printf("A::~A()\n"); }
14 };
15 
16 struct B : public A {
BB17   B() {};
BB18   B(const B& Other) : A(Other) { printf("B::B(const B&)\n"); }
~BB19   ~B() { printf("B::~B()\n"); }
20 };
21 
22 struct C : public B {
CC23   C() {};
CC24   C(const C& Other) : B(Other) { printf("C::C(const C&)\n"); }
~CC25   ~C() { printf("C::~C()\n"); }
26 };
27 
28 struct X {
operator B&X29 	operator B&() {printf("X::operator B&()\n"); return b; }
operator C&X30 	operator C&() {printf("X::operator C&()\n"); return c; }
XX31  	X (const X&) { printf("X::X(const X&)\n"); }
XX32  	X () { printf("X::X()\n"); }
~XX33  	~X () { printf("X::~X()\n"); }
34 	B b;
35 	C c;
36 };
37 
f(A)38 void f(A) {
39   printf("f(A)\n");
40 }
41 
42 
func(X x)43 void func(X x)
44 {
45   f (x);
46 }
47 
main()48 int main()
49 {
50     X x;
51     func(x);
52 }
53 
54 struct Base;
55 
56 struct Root {
operator Base&Root57   operator Base&() { exit(1); }
58 };
59 
60 struct Derived;
61 
62 struct Base : Root {
BaseBase63   Base(const Base&) { printf("Base::(const Base&)\n"); }
BaseBase64   Base() { printf("Base::Base()\n"); }
operator Derived&Base65   operator Derived&() { exit(1); }
66 };
67 
68 struct Derived : Base {
69 };
70 
foo(Base)71 void foo(Base) {}
72 
test(Derived bb)73 void test(Derived bb)
74 {
75 	// CHECK-LP64-NOT: callq    __ZN4BasecvR7DerivedEv
76 	// CHECK-LP32-NOT: callq    L__ZN4BasecvR7DerivedEv
77         foo(bb);
78 }
79 // CHECK-LP64: callq    __ZN1XcvR1BEv
80 // CHECK-LP64: callq    __ZN1AC1ERKS_
81 
82 // CHECK-LP32: calll     L__ZN1XcvR1BEv
83 // CHECK-LP32: calll     L__ZN1AC1ERKS_
84 
85 
86