xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/default-arg-temps.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc struct T {
4f4a2713aSLionel Sambuc   T();
5f4a2713aSLionel Sambuc   ~T();
6f4a2713aSLionel Sambuc };
7f4a2713aSLionel Sambuc 
8f4a2713aSLionel Sambuc void f(const T& t = T());
9f4a2713aSLionel Sambuc 
10f4a2713aSLionel Sambuc class X { // ...
11f4a2713aSLionel Sambuc public:
12f4a2713aSLionel Sambuc         X();
13f4a2713aSLionel Sambuc         X(const X&, const T& t = T());
14f4a2713aSLionel Sambuc };
15f4a2713aSLionel Sambuc 
16f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z1gv()
g()17f4a2713aSLionel Sambuc void g() {
18f4a2713aSLionel Sambuc   // CHECK:      call void @_ZN1TC1Ev([[T:%.*]]* [[AGG1:%.*]])
19*0a6a1f1dSLionel Sambuc   // CHECK-NEXT: call void @_Z1fRK1T([[T]]* dereferenceable({{[0-9]+}}) [[AGG1]])
20f4a2713aSLionel Sambuc   // CHECK-NEXT: call void @_ZN1TD1Ev([[T]]* [[AGG1]])
21f4a2713aSLionel Sambuc   f();
22f4a2713aSLionel Sambuc 
23f4a2713aSLionel Sambuc   // CHECK-NEXT: call void @_ZN1TC1Ev([[T:%.*]]* [[AGG2:%.*]])
24*0a6a1f1dSLionel Sambuc   // CHECK-NEXT: call void @_Z1fRK1T([[T]]* dereferenceable({{[0-9]+}}) [[AGG2]])
25f4a2713aSLionel Sambuc   // CHECK-NEXT: call void @_ZN1TD1Ev([[T]]* [[AGG2]])
26f4a2713aSLionel Sambuc   f();
27f4a2713aSLionel Sambuc 
28f4a2713aSLionel Sambuc   // CHECK-NEXT: call void @_ZN1XC1Ev(
29f4a2713aSLionel Sambuc   X a;
30f4a2713aSLionel Sambuc 
31f4a2713aSLionel Sambuc   // CHECK-NEXT: call void @_ZN1TC1Ev(
32f4a2713aSLionel Sambuc   // CHECK-NEXT: call void @_ZN1XC1ERKS_RK1T(
33f4a2713aSLionel Sambuc   // CHECK-NEXT: call void @_ZN1TD1Ev(
34f4a2713aSLionel Sambuc   X b(a);
35f4a2713aSLionel Sambuc 
36f4a2713aSLionel Sambuc   // CHECK-NEXT: call void @_ZN1TC1Ev(
37f4a2713aSLionel Sambuc   // CHECK-NEXT: call void @_ZN1XC1ERKS_RK1T(
38f4a2713aSLionel Sambuc   // CHECK-NEXT: call void @_ZN1TD1Ev(
39f4a2713aSLionel Sambuc   X c = a;
40f4a2713aSLionel Sambuc }
41f4a2713aSLionel Sambuc 
42f4a2713aSLionel Sambuc 
43f4a2713aSLionel Sambuc class obj{ int a; float b; double d; };
44f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z1hv()
h()45f4a2713aSLionel Sambuc void h() {
46f4a2713aSLionel Sambuc   // CHECK: call void @llvm.memset.p0i8.i64(
47f4a2713aSLionel Sambuc   obj o = obj();
48f4a2713aSLionel Sambuc }
49f4a2713aSLionel Sambuc 
50f4a2713aSLionel Sambuc // PR7028 - mostly this shouldn't crash
51f4a2713aSLionel Sambuc namespace test1 {
52f4a2713aSLionel Sambuc   struct A { A(); };
53f4a2713aSLionel Sambuc   struct B { B(); ~B(); };
54f4a2713aSLionel Sambuc 
55f4a2713aSLionel Sambuc   struct C {
56f4a2713aSLionel Sambuc     C(const B &file = B());
57f4a2713aSLionel Sambuc   };
C(const B & file)58f4a2713aSLionel Sambuc   C::C(const B &file) {}
59f4a2713aSLionel Sambuc 
60f4a2713aSLionel Sambuc   struct D {
61f4a2713aSLionel Sambuc     C c;
62f4a2713aSLionel Sambuc     A a;
63f4a2713aSLionel Sambuc 
64f4a2713aSLionel Sambuc     // CHECK-LABEL: define linkonce_odr void @_ZN5test11DC2Ev(%"struct.test1::D"* %this) unnamed_addr
65f4a2713aSLionel Sambuc     // CHECK:      call void @_ZN5test11BC1Ev(
66f4a2713aSLionel Sambuc     // CHECK-NEXT: call void @_ZN5test11CC1ERKNS_1BE(
67f4a2713aSLionel Sambuc     // CHECK-NEXT: call void @_ZN5test11BD1Ev(
68f4a2713aSLionel Sambuc     // CHECK:      call void @_ZN5test11AC1Ev(
Dtest1::D69f4a2713aSLionel Sambuc     D() : c(), a() {}
70f4a2713aSLionel Sambuc   };
71f4a2713aSLionel Sambuc 
72f4a2713aSLionel Sambuc   D d;
73f4a2713aSLionel Sambuc }
74