[ELF] Avoid make in elf::writeARMCmseImportLib
[llvm-project.git] / clang / test / CodeGenCXX / meminit-initializers-odr.cpp
blobb22b99db03a63b0858fbd8e0cdc5cfbbc0e68f59
1 // RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s
3 struct ThisShouldBeCalled {
4 ThisShouldBeCalled() {}
5 };
7 template <typename T>
8 struct ThisShouldBeCalledTPL {
9 ThisShouldBeCalledTPL() {}
12 consteval int f () {
13 return 42;
16 struct WithConsteval {
17 WithConsteval(int x = f()) {}
20 template <typename T>
21 struct WithConstevalTPL {
22 WithConstevalTPL(T x = f()) {}
26 struct Base {
27 ThisShouldBeCalled y = {};
30 struct S : Base {
31 ThisShouldBeCalledTPL<int> A = {};
32 WithConsteval B = {};
33 WithConstevalTPL<double> C = {};
35 void Do(S = S{}) {}
37 void test() {
38 Do();
41 // CHECK-LABEL: @_ZN18ThisShouldBeCalledC2Ev
42 // CHECK-LABEL: @_ZN21ThisShouldBeCalledTPLIiEC2Ev
43 // CHECK-LABEL: @_ZN13WithConstevalC2Ei
44 // CHECK-LABEL: @_ZN16WithConstevalTPLIdEC2Ed
46 namespace check_arrays {
48 template <typename T>
49 struct inner {
50 inner() {}
53 struct S {
54 inner<int> a {};
57 class C {
58 S s[1]{};
61 int f() {
62 C c;
63 return 0;
66 // CHECK-LABEL: @_ZN12check_arrays5innerIiEC2Ev
70 namespace check_field_inits_in_base_constructors {
72 template <typename>
73 struct ShouldBeODRUsed {
74 ShouldBeODRUsed() {}
76 class k {
77 // The private here is important,
78 // otherwise it would be aggregate initialized.
79 private:
80 ShouldBeODRUsed<k> a = {};
83 struct b {
84 k c{};
86 void test() { b d; }
88 // CHECK-LABEL: @_ZN38check_field_inits_in_base_constructors15ShouldBeODRUsedINS_1kEEC2Ev
92 namespace check_referenced_when_defined_in_default_parameter {
94 template <typename T>
95 struct Test {
96 Test(auto&&) {}
99 struct Options {
100 Test<bool(bool x)> identity = [](bool x) -> bool { return x; };
103 struct Wrapper {
104 Wrapper(const Options& options = Options());
107 void Func() { Options options; }
109 // CHECK-LABEL: @_ZN50check_referenced_when_defined_in_default_parameter7OptionsC2Ev
110 // CHECK-LABEL: @_ZN50check_referenced_when_defined_in_default_parameter4TestIFbbEEC1INS_7Options8identityMUlbE_EEEOT_
111 // CHECK-LABEL: @_ZN50check_referenced_when_defined_in_default_parameter4TestIFbbEEC2INS_7Options8identityMUlbE_EEEOT_
115 namespace lambda_body {
116 template <typename a>
117 int templated_func() {
118 return 0;
120 struct test_body {
121 int mem = templated_func<int>();
123 struct test_capture {
124 int mem = templated_func<double>();
127 struct S {
128 int a = [_ = test_capture{}] { (void)test_body{}; return 0;}();
131 void test() {
132 S s;
135 // CHECK-LABEL: define{{.*}} @_ZN11lambda_body14templated_funcIdEEiv
136 // CHECK-LABEL: define{{.*}} @_ZNK11lambda_body1S1aMUlvE_clEv
137 // CHECK-LABEL: define{{.*}} @_ZN11lambda_body14templated_funcIiEEiv