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