xref: /llvm-project/clang/test/CodeGenCXX/cxx2c-consteval-propagate.cpp (revision 8698262a4365bf22b5b0c96e77bfecd3dcf084a7)
1*8698262aSCorentin Jabot // RUN: %clang_cc1 -emit-llvm %s -std=c++20 -triple x86_64-unknown-linux-gnu -o - | FileCheck %s
2*8698262aSCorentin Jabot 
3*8698262aSCorentin Jabot namespace GH63742 {
4*8698262aSCorentin Jabot 
5*8698262aSCorentin Jabot void side_effect();
f(int x)6*8698262aSCorentin Jabot consteval int f(int x) {
7*8698262aSCorentin Jabot     if (!__builtin_is_constant_evaluated()) side_effect();
8*8698262aSCorentin Jabot     return x;
9*8698262aSCorentin Jabot }
10*8698262aSCorentin Jabot struct SS {
11*8698262aSCorentin Jabot     int x = f(42);
12*8698262aSCorentin Jabot     SS();
13*8698262aSCorentin Jabot };
SS()14*8698262aSCorentin Jabot SS::SS(){}
15*8698262aSCorentin Jabot 
16*8698262aSCorentin Jabot }
17*8698262aSCorentin Jabot 
18*8698262aSCorentin Jabot // CHECK-LABEL: @_ZN7GH637422SSC2Ev
19*8698262aSCorentin Jabot // CHECK-NOT:   call
20*8698262aSCorentin Jabot // CHECK:       store i32 42, ptr {{.*}}
21*8698262aSCorentin Jabot // CHECK:       ret void
22