Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / const-init-cxx2a.cpp
blob3c83a9c94adecd55aed54c4c10006c991871ab72
1 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s -std=c++2a | FileCheck %s --implicit-check-not=cxx_global_var_init --implicit-check-not=cxa_atexit
3 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-pch -o %t.pch %s -std=c++2a
4 // RUN: %clang_cc1 -triple x86_64-linux-gnu -include-pch %t.pch -x c++ /dev/null -emit-llvm -o - -std=c++2a | FileCheck %s --implicit-check-not=cxx_global_var_init --implicit-check-not=cxa_atexit
6 // CHECK: @a ={{.*}} global i32 123,
7 int a = (delete new int, 123);
9 struct B {
10 constexpr B() {}
11 constexpr ~B() { n *= 5; }
12 int n = 123;
14 // CHECK: @b ={{.*}} constant {{.*}} i32 123
15 extern constexpr B b = B();
17 // CHECK: @_ZL1c = internal constant {{.*}} i32 123
18 const B c;
19 int use_c() { return c.n; }
21 struct D {
22 int n;
23 constexpr ~D() {}
25 D d;
26 // CHECK: @d ={{.*}} global {{.*}} zeroinitializer
28 D d_arr[3];
29 // CHECK: @d_arr ={{.*}} global {{.*}} zeroinitializer
31 thread_local D d_tl;
32 // CHECK: @d_tl ={{.*}} thread_local global {{.*}} zeroinitializer
34 // CHECK-NOT: @llvm.global_ctors
36 // CHECK-LABEL: define {{.*}} @_Z1fv(
37 void f() {
38 // CHECK-NOT: call
39 // CHECK: call {{.*}}memcpy
40 // CHECK-NOT: call
41 // CHECK: call {{.*}}memset
42 // CHECK-NOT: call
43 // CHECK: }
44 constexpr B b;
45 D d = D();
48 // CHECK-LABEL: define {{.*}} @_Z1gv(
49 void g() {
50 // CHECK-NOT: call
51 // CHECK-NOT: cxa_guard
52 // CHECK-NOT: _ZGV
53 // CHECK: }
54 static constexpr B b1;
55 static const B b2;
56 static D d;
57 thread_local D d_tl;