testsuite: update mangling
[official-gcc.git] / gcc / testsuite / g++.dg / cpp2a / is-constant-evaluated9.C
blob5e405e71cc0c3aadf67882e33c75aaf8f4c16d3a
1 // PR c++/91428 - warn about std::is_constant_evaluated in if constexpr.
2 // { dg-do compile { target c++20 } }
3 // { dg-options "-Wtautological-compare" }
5 namespace std {
6   constexpr inline bool
7   is_constant_evaluated () noexcept
8   {
9     return __builtin_is_constant_evaluated (); 
10   }
13 constexpr int
14 foo(int i)
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;
22 constexpr int
23 foo2(int i)
25   if constexpr (__builtin_is_constant_evaluated ()) // { dg-warning ".std::is_constant_evaluated. always evaluates to true in .if constexpr." }
26     return 42;
27   else
28     return i;
31 constexpr int
32 foo3(int i)
34   // I is not a constant expression but we short-circuit it.
35   if constexpr (__builtin_is_constant_evaluated () || i) // { dg-warning ".std::is_constant_evaluated. always evaluates to true in .if constexpr." }
36     return 42;
37   else
38     return i;
41 constexpr int
42 foo4(int i)
44   const int j = 0;
45   if constexpr (j && __builtin_is_constant_evaluated ()) // { dg-warning ".std::is_constant_evaluated. always evaluates to true in .if constexpr." }
46     return 42;
47   else
48     return i;