1// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s
2
3struct A {
4  A();
5  A(const A&);
6  A(A&);
7  ~A();
8};
9
10struct B {
11  B();
12  B(B&);
13};
14
15struct C {
16  C() {}
17  C(C& other, A a = A());
18  int i, j;
19};
20
21struct POD {
22  id myobjc;
23  int array[3][4];
24};
25
26struct D : A, B, virtual C {
27  D();
28  int scalar;
29  int scalar_array[2][3];
30  B class_member;
31  C class_member_array[2][3];
32  POD pod_array[2][3];
33
34  union {
35    int x;
36    float f[3];
37  };
38};
39
40void f(D d) {
41  D d2(d);
42}
43
44// CHECK-LABEL: define linkonce_odr void @_ZN1DC1ERS_(%struct.D* {{[^,]*}} %this, %struct.D* nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %0) unnamed_addr
45// CHECK: call void @_ZN1AC1Ev
46// CHECK: call void @_ZN1CC2ERS_1A
47// CHECK: call void @_ZN1AD1Ev
48// CHECK: call void @_ZN1AC2ERS_
49// CHECK: call void @_ZN1BC2ERS_
50// CHECK: {{call void @llvm.memcpy.p0i8.p0i8.i64.*i64 24}}
51// CHECK: call void @_ZN1BC1ERS_
52// CHECK: br label
53// CHECK: call void @_ZN1AC1Ev
54// CHECK: call void @_ZN1CC1ERS_1A
55// CHECK: call void @_ZN1AD1Ev
56// CHECK: {{icmp eq.*, 3}}
57// CHECK: br i1
58// CHECK: {{icmp eq.*, 2}}
59// CHECK: br i1
60// CHECK: {{call.*@objc_memmove_collectable}}
61// CHECK: {{call void @llvm.memcpy.p0i8.p0i8.i64.*i64 12}}
62// CHECK: ret void
63
64
65template<class T> struct X0 { void f0(T * ) { } };
66template <class > struct X1 { X1( X1& , int = 0 ) { } };
67struct X2 { X1<int> result; };
68void test_X2()
69{
70  typedef X2 impl;
71  typedef X0<impl> pimpl;
72  impl* i;
73  pimpl pdata;
74  pdata.f0( new impl(*i));
75}
76