gcc/testsuite/g++.dg/cpp2a/consteval41.C
raw| 1 | // PR c++/119150 |
| 2 | // { dg-do run { target c++20 } } |
| 3 | |
| 4 | consteval bool |
| 5 | foo (bool x) |
| 6 | { |
| 7 | return x; |
| 8 | } |
| 9 | |
| 10 | constexpr bool |
| 11 | bar () |
| 12 | { |
| 13 | #if __cpp_if_consteval >= 202106L |
| 14 | if consteval |
| 15 | { |
| 16 | return true; |
| 17 | } |
| 18 | else |
| 19 | { |
| 20 | return false; |
| 21 | } |
| 22 | #else |
| 23 | return __builtin_is_constant_evaluated (); |
| 24 | #endif |
| 25 | } |
| 26 | |
| 27 | int |
| 28 | main () |
| 29 | { |
| 30 | bool a = false; |
| 31 | a = foo (bar ()); |
| 32 | if (!a) |
| 33 | __builtin_abort (); |
| 34 | bool b = foo (bar ()); |
| 35 | if (!b) |
| 36 | __builtin_abort (); |
| 37 | } |