summaryrefslogtreecommitdiff
path: root/clang/test/CodeGenCXX/default-arg-temps.cpp
blob: 3d741d502834290c8def1fb66aff930418184850 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s

struct T {
  T();
  ~T();
};

void f(const T& t = T());

class X { // ...
public:
        X();
        X(const X&, const T& t = T());
};

// CHECK: define void @_Z1gv()
void g() {
  // CHECK:      call void @_ZN1TC1Ev([[T:%.*]]* [[AGG1:%.*]])
  // CHECK-NEXT: call void @_Z1fRK1T([[T]]* [[AGG1]])
  // CHECK-NEXT: call void @_ZN1TD1Ev([[T]]* [[AGG1]])
  f();

  // CHECK-NEXT: call void @_ZN1TC1Ev([[T:%.*]]* [[AGG2:%.*]])
  // CHECK-NEXT: call void @_Z1fRK1T([[T]]* [[AGG2]])
  // CHECK-NEXT: call void @_ZN1TD1Ev([[T]]* [[AGG2]])
  f();

  // CHECK-NEXT: call void @_ZN1XC1Ev(
  X a;

  // CHECK-NEXT: call void @_ZN1TC1Ev(
  // CHECK-NEXT: call void @_ZN1XC1ERKS_RK1T(
  // CHECK-NEXT: call void @_ZN1TD1Ev(
  X b(a);

  // CHECK-NEXT: call void @_ZN1TC1Ev(
  // CHECK-NEXT: call void @_ZN1XC1ERKS_RK1T(
  // CHECK-NEXT: call void @_ZN1TD1Ev(
  X c = a;
}


class obj{ int a; float b; double d; };
// CHECK: define void @_Z1hv()
void h() {
  // CHECK: call void @llvm.memset.p0i8.i64(
  obj o = obj();
}

// PR7028 - mostly this shouldn't crash
namespace test1 {
  struct A { A(); };
  struct B { B(); ~B(); };

  struct C {
    C(const B &file = B());
  };
  C::C(const B &file) {}

  struct D {
    C c;
    A a;

    // CHECK: define linkonce_odr void @_ZN5test11DC2Ev(%"struct.test1::D"* %this) unnamed_addr
    // CHECK:      call void @_ZN5test11BC1Ev(
    // CHECK-NEXT: call void @_ZN5test11CC1ERKNS_1BE(
    // CHECK-NEXT: call void @_ZN5test11BD1Ev(
    // CHECK:      call void @_ZN5test11AC1Ev(
    D() : c(), a() {}
  };

  D d;
}