| 1 |
// P0466R5 |
| 2 |
// { dg-do run { target c++20 } } |
| 3 |
// { dg-options "" } |
| 4 |
|
| 5 |
namespace std |
| 6 |
{ |
| 7 |
template <class S, class M> |
| 8 |
constexpr bool |
| 9 |
is_pointer_interconvertible_with_class (M S::*m) noexcept |
| 10 |
{ |
| 11 |
return __builtin_is_pointer_interconvertible_with_class (m); |
| 12 |
} |
| 13 |
} |
| 14 |
|
| 15 |
struct W { struct { int a; long b; }; int c; }; |
| 16 |
union X { int a; struct { short b; long c; }; long long d; }; |
| 17 |
struct D { int x; private: int y; }; |
| 18 |
union Y { int a; struct { short b; long c; D z; }; long long d; }; |
| 19 |
|
| 20 |
int |
| 21 |
main () |
| 22 |
{ |
| 23 |
auto t1 = &W::a; |
| 24 |
if (!std::is_pointer_interconvertible_with_class (t1)) |
| 25 |
__builtin_abort (); |
| 26 |
auto t2 = &W::b; |
| 27 |
if (std::is_pointer_interconvertible_with_class (t2)) |
| 28 |
__builtin_abort (); |
| 29 |
auto t3 = &W::c; |
| 30 |
if (std::is_pointer_interconvertible_with_class (t3)) |
| 31 |
__builtin_abort (); |
| 32 |
auto t4 = &X::a; |
| 33 |
if (!std::is_pointer_interconvertible_with_class (t4)) |
| 34 |
__builtin_abort (); |
| 35 |
auto t5 = &X::b; |
| 36 |
if (!std::is_pointer_interconvertible_with_class (t5)) |
| 37 |
__builtin_abort (); |
| 38 |
auto t6 = &X::c; |
| 39 |
if (std::is_pointer_interconvertible_with_class (t6)) |
| 40 |
__builtin_abort (); |
| 41 |
auto t7 = &X::d; |
| 42 |
if (!std::is_pointer_interconvertible_with_class (t7)) |
| 43 |
__builtin_abort (); |
| 44 |
auto t8 = &Y::a; |
| 45 |
if (!std::is_pointer_interconvertible_with_class (t8)) |
| 46 |
__builtin_abort (); |
| 47 |
auto t9 = &Y::b; |
| 48 |
if (std::is_pointer_interconvertible_with_class (t9)) |
| 49 |
__builtin_abort (); |
| 50 |
auto t10 = &Y::c; |
| 51 |
if (std::is_pointer_interconvertible_with_class (t10)) |
| 52 |
__builtin_abort (); |
| 53 |
auto t11 = &Y::z; |
| 54 |
if (std::is_pointer_interconvertible_with_class (t11)) |
| 55 |
__builtin_abort (); |
| 56 |
auto t12 = &Y::d; |
| 57 |
if (!std::is_pointer_interconvertible_with_class (t12)) |
| 58 |
__builtin_abort (); |
| 59 |
} |