brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · b22b99d Raw
141 lines · cpp
1// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s2 3struct ThisShouldBeCalled {4    ThisShouldBeCalled() {}5};6 7template <typename T>8struct ThisShouldBeCalledTPL {9    ThisShouldBeCalledTPL() {}10};11 12consteval int f () {13    return 42;14}15 16struct WithConsteval {17    WithConsteval(int x = f()) {}18};19 20template <typename T>21struct WithConstevalTPL {22    WithConstevalTPL(T x = f()) {}23};24 25 26struct Base {27    ThisShouldBeCalled y = {};28};29 30struct S : Base {31    ThisShouldBeCalledTPL<int> A =  {};32    WithConsteval B = {};33    WithConstevalTPL<double> C = {};34};35void Do(S = S{}) {}36 37void test() {38    Do();39}40 41// CHECK-LABEL: @_ZN18ThisShouldBeCalledC2Ev42// CHECK-LABEL: @_ZN21ThisShouldBeCalledTPLIiEC2Ev43// CHECK-LABEL: @_ZN13WithConstevalC2Ei44// CHECK-LABEL: @_ZN16WithConstevalTPLIdEC2Ed45 46namespace check_arrays {47 48template <typename T>49struct inner {50    inner() {}51};52 53struct S {54   inner<int> a {};55};56 57class C {58    S s[1]{};59};60 61int f() {62    C c;63    return 0;64}65 66// CHECK-LABEL: @_ZN12check_arrays5innerIiEC2Ev67 68}69 70namespace check_field_inits_in_base_constructors {71 72template <typename>73struct ShouldBeODRUsed {74  ShouldBeODRUsed() {}75};76class k {77// The private here is important,78// otherwise it would be aggregate initialized.79private:80  ShouldBeODRUsed<k> a = {};81};82 83struct b {84  k c{};85};86void test() { b d; }87 88// CHECK-LABEL: @_ZN38check_field_inits_in_base_constructors15ShouldBeODRUsedINS_1kEEC2Ev89 90}91 92namespace check_referenced_when_defined_in_default_parameter {93 94template <typename T>95struct Test {96    Test(auto&&) {}97};98 99struct Options {100    Test<bool(bool x)> identity = [](bool x) -> bool { return x; };101};102 103struct Wrapper {104  Wrapper(const Options& options = Options());105};106 107void Func() { Options options; }108 109// CHECK-LABEL: @_ZN50check_referenced_when_defined_in_default_parameter7OptionsC2Ev110// CHECK-LABEL: @_ZN50check_referenced_when_defined_in_default_parameter4TestIFbbEEC1INS_7Options8identityMUlbE_EEEOT_111// CHECK-LABEL: @_ZN50check_referenced_when_defined_in_default_parameter4TestIFbbEEC2INS_7Options8identityMUlbE_EEEOT_112 113}114 115namespace lambda_body {116template <typename a>117int templated_func() {118    return 0;119}120struct test_body {121  int mem = templated_func<int>();122};123struct test_capture {124  int mem = templated_func<double>();125};126 127struct S {128  int a = [_ = test_capture{}] { (void)test_body{}; return 0;}();129};130 131void test() {132    S s;133}134 135// CHECK-LABEL: define{{.*}} @_ZN11lambda_body14templated_funcIdEEiv136// CHECK-LABEL: define{{.*}} @_ZNK11lambda_body1S1aMUlvE_clEv137// CHECK-LABEL: define{{.*}} @_ZN11lambda_body14templated_funcIiEEiv138 139 140}141