| 1 |
// { dg-do compile { target c++11 } } |
| 2 |
// { dg-options "" } |
| 3 |
|
| 4 |
namespace std { |
| 5 |
constexpr inline bool |
| 6 |
is_constant_evaluated () noexcept |
| 7 |
{ |
| 8 |
return __builtin_is_constant_evaluated (); |
| 9 |
} |
| 10 |
} |
| 11 |
|
| 12 |
struct A { explicit (!__builtin_is_constant_evaluated ()) A (int); }; // { dg-warning "'explicit\\(bool\\)' only available with" "" { target c++17_down } } |
| 13 |
struct B { explicit (!std::is_constant_evaluated ()) B (int); }; // { dg-warning "'explicit\\(bool\\)' only available with" "" { target c++17_down } } |
| 14 |
struct C { explicit (__builtin_is_constant_evaluated ()) C (int); }; // { dg-warning "'explicit\\(bool\\)' only available with" "" { target c++17_down } } |
| 15 |
struct D { explicit (std::is_constant_evaluated ()) D (int); }; // { dg-warning "'explicit\\(bool\\)' only available with" "" { target c++17_down } } |
| 16 |
A a = 1; |
| 17 |
B b = 2; |
| 18 |
C c = 3; // { dg-error "conversion from 'int' to non-scalar type 'C' requested" } |
| 19 |
D d = 4; // { dg-error "conversion from 'int' to non-scalar type 'D' requested" } |