Debian Codegraph @

gcc/testsuite/g++.dg/opt/is_constant_evaluated2.C

raw
1 // PR c++/97553
2 // { dg-do compile { target c++11 } }
3 // { dg-additional-options "-O -fdump-tree-original" }
4
5 constexpr int foo() {
6 return __builtin_is_constant_evaluated() + 1;
7 }
8
9 #if __cpp_if_consteval
10 constexpr int bar() {
11 if consteval {
12 return 5;
13 } else {
14 return 4;
15 }
16 }
17 #endif
18
19 int p, q;
20
21 int main() {
22 p = foo();
23 #if __cpp_if_consteval
24 q = bar();
25 #endif
26 }
27
28 // { dg-final { scan-tree-dump "p = 1" "original" } }
29 // { dg-final { scan-tree-dump-not "= foo" "original" } }
30
31 // { dg-final { scan-tree-dump "q = 4" "original" { target c++23 } } }
32 // { dg-final { scan-tree-dump-not "= bar" "original" { target c++23 } } }