| 1 |
// { dg-do compile { target c++2a } } |
| 2 |
// { dg-options "-Wtautological-compare" } |
| 3 |
|
| 4 |
namespace std { |
| 5 |
constexpr inline bool |
| 6 |
is_constant_evaluated () noexcept |
| 7 |
{ |
| 8 |
return __builtin_is_constant_evaluated (); |
| 9 |
} |
| 10 |
} |
| 11 |
|
| 12 |
template<typename> |
| 13 |
constexpr int |
| 14 |
foo(int i) |
| 15 |
{ |
| 16 |
if constexpr (std::is_constant_evaluated ()) // { dg-warning ".std::is_constant_evaluated. always evaluates to true in .if constexpr." } |
| 17 |
return 42; |
| 18 |
else |
| 19 |
return i; |
| 20 |
} |
| 21 |
|
| 22 |
template<typename> |
| 23 |
constexpr int |
| 24 |
foo2(int i) |
| 25 |
{ |
| 26 |
if constexpr (__builtin_is_constant_evaluated ()) // { dg-warning ".std::is_constant_evaluated. always evaluates to true in .if constexpr." } |
| 27 |
return 42; |
| 28 |
else |
| 29 |
return i; |
| 30 |
} |