| 1 |
// P2564R3 |
| 2 |
// { dg-do compile { target c++20 } } |
| 3 |
|
| 4 |
consteval int |
| 5 |
zero (int) |
| 6 |
{ |
| 7 |
return 0; |
| 8 |
} |
| 9 |
|
| 10 |
constexpr int |
| 11 |
f1 (auto i) |
| 12 |
{ |
| 13 |
return zero (i); |
| 14 |
} |
| 15 |
|
| 16 |
constexpr int |
| 17 |
f2 (auto i) |
| 18 |
{ |
| 19 |
return f1 (i); |
| 20 |
} |
| 21 |
|
| 22 |
constexpr int |
| 23 |
f3 (auto i) |
| 24 |
{ |
| 25 |
return f2 (i); |
| 26 |
} |
| 27 |
|
| 28 |
constexpr int |
| 29 |
f4 (auto i) |
| 30 |
{ |
| 31 |
return f3 (i); |
| 32 |
} |
| 33 |
|
| 34 |
constexpr int |
| 35 |
f5 (auto i) |
| 36 |
{ |
| 37 |
return f4 (i); |
| 38 |
} |
| 39 |
|
| 40 |
constexpr int |
| 41 |
f6 (auto) |
| 42 |
{ |
| 43 |
// This call is a constant expression, so don't promote f6. |
| 44 |
return f5 (42); |
| 45 |
} |
| 46 |
|
| 47 |
constexpr int |
| 48 |
f7 (auto) |
| 49 |
{ |
| 50 |
// This call is a constant expression, so don't promote f7. |
| 51 |
return zero (42); |
| 52 |
} |
| 53 |
|
| 54 |
auto p1 = &f5<int>; // { dg-error "taking address" } |
| 55 |
static auto p2 = &f4<int>; // { dg-error "taking address" } |
| 56 |
auto p3 = &f6<int>; |
| 57 |
static auto p4 = &f6<int>; |
| 58 |
auto p5 = &f7<int>; |
| 59 |
static auto p6 = &f7<int>; |
| 60 |
|
| 61 |
void |
| 62 |
g () |
| 63 |
{ |
| 64 |
static auto q1 = &f4<int>; // { dg-error "taking address" } |
| 65 |
static auto q2 = &f6<int>; |
| 66 |
static auto q3 = &f7<int>; |
| 67 |
} |