blob: 37550c42193c74961494d3a54474f7f7e98fb186 [file] [log] [blame]
Fariborz Jahanian370c8842009-08-10 17:20:45 +00001// RUN: clang-cc -triple x86_64-apple-darwin -S %s -o %t-64.s &&
2// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s &&
Fariborz Jahanian942f4f32009-08-08 23:32:22 +00003// RUN: clang-cc -triple i386-apple-darwin -S %s -o %t-32.s &&
4// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s &&
5// RUN: true
6
7extern "C" int printf(...);
8
9int init = 100;
10
11struct M {
12 int iM;
13 M() : iM(init++) {}
14};
15
16struct N {
17 int iN;
18 N() : iN(200) {}
19 N(N const & arg){this->iN = arg.iN; }
20};
21
22struct P {
23 int iP;
24 P() : iP(init++) {}
25};
26
27
28struct X : M, N, P { // ...
Mike Stump1eb44332009-09-09 15:08:12 +000029 X() : f1(1.0), d1(2.0), i1(3), name("HELLO"), bf1(0xff), bf2(0xabcd),
30 au_i1(1234), au1_4("MASKED") {}
31 P p0;
32 void pr() {
33 printf("iM = %d iN = %d, m1.iM = %d\n", iM, iN, m1.iM);
34 printf("im = %d p0.iP = %d, p1.iP = %d\n", iP, p0.iP, p1.iP);
35 printf("f1 = %f d1 = %f i1 = %d name(%s) \n", f1, d1, i1, name);
36 printf("bf1 = %x bf2 = %x\n", bf1, bf2);
37 printf("au_i2 = %d\n", au_i2);
38 printf("au1_1 = %s\n", au1_1);
39 }
40 M m1;
41 P p1;
42 float f1;
43 double d1;
44 int i1;
45 const char *name;
46 unsigned bf1 : 8;
47 unsigned bf2 : 16;
Fariborz Jahaniane6494122009-08-11 18:49:54 +000048
Mike Stump1eb44332009-09-09 15:08:12 +000049 union {
50 int au_i1;
51 int au_i2;
52 };
53 union {
54 const char * au1_1;
55 float au1_2;
56 int au1_3;
57 const char * au1_4;
58 };
Fariborz Jahanian942f4f32009-08-08 23:32:22 +000059};
60
Fariborz Jahanianeb0b6d52009-08-21 18:30:26 +000061static int ix = 1;
62// class with user-defined copy constructor.
63struct S {
64 S() : iS(ix++) { }
65 S(const S& arg) { *this = arg; }
66 int iS;
67};
68
69// class with trivial copy constructor.
70struct I {
71 I() : iI(ix++) { }
72 int iI;
73};
74
75struct XM {
76 XM() { }
77 double dXM;
78 S ARR_S[3][4][2];
79 void pr() {
80 for (unsigned i = 0; i < 3; i++)
81 for (unsigned j = 0; j < 4; j++)
82 for (unsigned k = 0; k < 2; k++)
83 printf("ARR_S[%d][%d][%d] = %d\n", i,j,k, ARR_S[i][j][k].iS);
84 for (unsigned i = 0; i < 3; i++)
85 for (unsigned k = 0; k < 2; k++)
86 printf("ARR_I[%d][%d] = %d\n", i,k, ARR_I[i][k].iI);
87 }
88 I ARR_I[3][2];
89};
90
Mike Stump1eb44332009-09-09 15:08:12 +000091int main() {
92 X a;
93 X b(a);
94 b.pr();
95 X x;
96 X c(x);
97 c.pr();
Fariborz Jahanianeb0b6d52009-08-21 18:30:26 +000098
Mike Stump1eb44332009-09-09 15:08:12 +000099 XM m0;
100 XM m1 = m0;
101 m1.pr();
Fariborz Jahanian942f4f32009-08-08 23:32:22 +0000102}
Mike Stump1eb44332009-09-09 15:08:12 +0000103
Fariborz Jahanian942f4f32009-08-08 23:32:22 +0000104// CHECK-LP64: .globl __ZN1XC1ERK1X
105// CHECK-LP64: .weak_definition __ZN1XC1ERK1X
106// CHECK-LP64: __ZN1XC1ERK1X:
Fariborz Jahanian942f4f32009-08-08 23:32:22 +0000107
108// CHECK-LP32: .globl __ZN1XC1ERK1X
109// CHECK-LP32: .weak_definition __ZN1XC1ERK1X
110// CHECK-LP32: __ZN1XC1ERK1X: