Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/consteval-prop18.C

raw
1 // P2564R3
2 // { dg-do compile { target c++20 } }
3
4 consteval int id(int i) { return i; }
5
6 constexpr int
7 f (auto t)
8 {
9 return t + id (t);
10 }
11
12 constexpr int
13 f2 (auto t)
14 {
15 return t + f(t); // { dg-message "immediate-escalating expression .f<int>\\(t\\)." }
16 }
17
18 int z; // { dg-message "not const" }
19 auto y1 = f2 (42);
20 auto y2 = f2 (z); // { dg-error "value of .z. is not usable in a constant expression|call to consteval function" }