xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/global-array-destruction.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm %s -o - | FileCheck %s
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc extern "C" int printf(...);
4f4a2713aSLionel Sambuc 
5f4a2713aSLionel Sambuc int count;
6f4a2713aSLionel Sambuc 
7f4a2713aSLionel Sambuc struct S {
SS8f4a2713aSLionel Sambuc   S() : iS(++count) { printf("S::S(%d)\n", iS); }
~SS9f4a2713aSLionel Sambuc   ~S() { printf("S::~S(%d)\n", iS); }
10f4a2713aSLionel Sambuc   int iS;
11f4a2713aSLionel Sambuc };
12f4a2713aSLionel Sambuc 
13f4a2713aSLionel Sambuc 
14f4a2713aSLionel Sambuc S arr[2][1];
15f4a2713aSLionel Sambuc S s1;
16f4a2713aSLionel Sambuc S arr1[3];
17f4a2713aSLionel Sambuc static S sarr[4];
18f4a2713aSLionel Sambuc 
main()19f4a2713aSLionel Sambuc int main () {}
20f4a2713aSLionel Sambuc S arr2[2];
21f4a2713aSLionel Sambuc static S sarr1[4];
22f4a2713aSLionel Sambuc S s2;
23f4a2713aSLionel Sambuc S arr3[3];
24f4a2713aSLionel Sambuc 
25f4a2713aSLionel Sambuc // CHECK: call {{.*}} @__cxa_atexit
26f4a2713aSLionel Sambuc // CHECK: call {{.*}} @__cxa_atexit
27f4a2713aSLionel Sambuc // CHECK: call {{.*}} @__cxa_atexit
28f4a2713aSLionel Sambuc // CHECK: call {{.*}} @__cxa_atexit
29f4a2713aSLionel Sambuc // CHECK: call {{.*}} @__cxa_atexit
30f4a2713aSLionel Sambuc // CHECK: call {{.*}} @__cxa_atexit
31f4a2713aSLionel Sambuc // CHECK: call {{.*}} @__cxa_atexit
32f4a2713aSLionel Sambuc // CHECK: call {{.*}} @__cxa_atexit
33f4a2713aSLionel Sambuc 
34f4a2713aSLionel Sambuc struct T {
35f4a2713aSLionel Sambuc   double d;
36f4a2713aSLionel Sambuc   int n;
37f4a2713aSLionel Sambuc   ~T();
38f4a2713aSLionel Sambuc };
39f4a2713aSLionel Sambuc T t[2][3] = { 1.0, 2, 3.0, 4, 5.0, 6, 7.0, 8, 9.0, 10, 11.0, 12 };
40f4a2713aSLionel Sambuc 
41f4a2713aSLionel Sambuc // CHECK: call {{.*}} @__cxa_atexit
42f4a2713aSLionel Sambuc // CHECK: getelementptr inbounds ({{.*}} bitcast {{.*}}* @t to %struct.T*), i64 6
43f4a2713aSLionel Sambuc // CHECK: call void @_ZN1TD1Ev
44f4a2713aSLionel Sambuc // CHECK: icmp eq {{.*}} @t
45f4a2713aSLionel Sambuc // CHECK: br i1 {{.*}}
46f4a2713aSLionel Sambuc 
47f4a2713aSLionel Sambuc static T t2[2][3] = { 1.0, 2, 3.0, 4, 5.0, 6, 7.0, 8, 9.0, 10, 11.0, 12 };
48f4a2713aSLionel Sambuc 
49f4a2713aSLionel Sambuc // CHECK: call {{.*}} @__cxa_atexit
50f4a2713aSLionel Sambuc // CHECK: getelementptr inbounds ({{.*}} bitcast {{.*}}* @_ZL2t2 to %struct.T*), i64 6
51f4a2713aSLionel Sambuc // CHECK: call void @_ZN1TD1Ev
52f4a2713aSLionel Sambuc // CHECK: icmp eq {{.*}} @_ZL2t
53f4a2713aSLionel Sambuc // CHECK: br i1 {{.*}}
54f4a2713aSLionel Sambuc 
55f4a2713aSLionel Sambuc using U = T[2][3];
56f4a2713aSLionel Sambuc U &&u = U{ {{1.0, 2}, {3.0, 4}, {5.0, 6}}, {{7.0, 8}, {9.0, 10}, {11.0, 12}} };
57f4a2713aSLionel Sambuc 
58f4a2713aSLionel Sambuc // CHECK: call {{.*}} @__cxa_atexit
59*0a6a1f1dSLionel Sambuc // CHECK: getelementptr inbounds ({{.*}}* getelementptr inbounds ([2 x [3 x {{.*}}]]* @_ZGR1u_, i32 0, i32 0, i32 0), i64 6)
60f4a2713aSLionel Sambuc // CHECK: call void @_ZN1TD1Ev
61*0a6a1f1dSLionel Sambuc // CHECK: icmp eq {{.*}} @_ZGR1u_
62f4a2713aSLionel Sambuc // CHECK: br i1 {{.*}}
63