blob: 3144e941ef4276a19e9878a93b6605e772edd0c2 [file] [log] [blame]
Richard Smith802e2262013-02-02 01:13:06 +00001// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 -S -emit-llvm -o - %s -Wno-address-of-temporary | FileCheck %s
Eli Friedmanc60ccf52012-02-29 00:00:28 +00002
Richard Smith0dbe2fb2012-12-21 03:17:28 +00003// CHECK: @[[THREE_NULL_MEMPTRS:.*]] = private constant [3 x i32] [i32 -1, i32 -1, i32 -1]
4
Eli Friedmanc60ccf52012-02-29 00:00:28 +00005struct A { int a[1]; };
6typedef A x[];
7int f() {
8 x{{{1}}};
9 // CHECK: define i32 @_Z1fv
10 // CHECK: store i32 1
11 // (It's okay if the output changes here, as long as we don't crash.)
Richard Smith0dbe2fb2012-12-21 03:17:28 +000012 return 0;
13}
14
15namespace ValueInitArrayOfMemPtr {
16 struct S {};
17 typedef int (S::*p);
18 typedef p a[3];
19 void f(const a &);
20
21 struct Agg1 {
22 int n;
23 p x;
24 };
25
26 struct Agg2 {
27 int n;
28 a x;
29 };
30
31 struct S1 {
32 p x;
33 S1();
34 };
35
36 // CHECK: define void @_ZN22ValueInitArrayOfMemPtr1fEi
37 void f(int n) {
38 Agg1 a = { n };
39 // CHECK: store i32 -1,
40
41 Agg2 b = { n };
42 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %{{.*}}, i8* bitcast ([3 x i32]* @[[THREE_NULL_MEMPTRS]] to i8*), i32 12, i32 4, i1 false)
43 }
44
45 // CHECK: define void @_ZN22ValueInitArrayOfMemPtr1gEv
46 void g() {
47 // CHECK: store i32 -1,
48 f(a{});
49 }
Eli Friedmanc60ccf52012-02-29 00:00:28 +000050}
Richard Smith802e2262013-02-02 01:13:06 +000051
52namespace array_dtor {
53 struct S { S(); ~S(); };
54 using T = S[3];
55 void f(const T &);
Richard Smith3fa3fea2013-02-02 02:14:45 +000056 void f(T *);
Richard Smith802e2262013-02-02 01:13:06 +000057 // CHECK: define void @_ZN10array_dtor1gEv(
58 void g() {
59 // CHECK: %[[ARRAY:.*]] = alloca [3 x
60 // CHECK: br
61
62 // Construct loop.
63 // CHECK: call void @_ZN10array_dtor1SC1Ev(
64 // CHECK: br i1
65
66 // CHECK: call void @_ZN10array_dtor1fERA3_KNS_1SE(
67 // CHECK: br
68
69 // Destruct loop.
70 // CHECK: call void @_ZN10array_dtor1SD1Ev(
71 // CHECK: br i1
Richard Smith3fa3fea2013-02-02 02:14:45 +000072 f(T{});
Richard Smith802e2262013-02-02 01:13:06 +000073
74 // CHECK: ret void
Richard Smith802e2262013-02-02 01:13:06 +000075 }
76 // CHECK: define void @_ZN10array_dtor1hEv(
77 void h() {
78 // CHECK: %[[ARRAY:.*]] = alloca [3 x
79 // CHECK: br
80
81 // CHECK: call void @_ZN10array_dtor1SC1Ev(
82 // CHECK: br i1
83 T &&t = T{};
84
85 // CHECK: call void @_ZN10array_dtor1fERA3_KNS_1SE(
86 // CHECK: br
87 f(t);
88
89 // CHECK: call void @_ZN10array_dtor1SD1Ev(
90 // CHECK: br i1
91
92 // CHECK: ret void
93 }
Richard Smith3fa3fea2013-02-02 02:14:45 +000094 // CHECK: define void @_ZN10array_dtor1iEv(
95 void i() {
96 // CHECK: %[[ARRAY:.*]] = alloca [3 x
97 // CHECK: br
98
99 // CHECK: call void @_ZN10array_dtor1SC1Ev(
100 // CHECK: br i1
101
102 // CHECK: call void @_ZN10array_dtor1fEPA3_NS_1SE(
103 // CHECK: br
104
105 // CHECK: call void @_ZN10array_dtor1SD1Ev(
106 // CHECK: br i1
107 f(&T{});
108
109 // CHECK: ret void
110 }
Richard Smith802e2262013-02-02 01:13:06 +0000111}