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