| 1 |
// P0466R5 |
| 2 |
// { dg-do run { target c++20 } } |
| 3 |
|
| 4 |
namespace std |
| 5 |
{ |
| 6 |
template <class S, class M> |
| 7 |
constexpr bool |
| 8 |
is_pointer_interconvertible_with_class (M S::*m) noexcept |
| 9 |
{ |
| 10 |
return __builtin_is_pointer_interconvertible_with_class (m); |
| 11 |
} |
| 12 |
} |
| 13 |
|
| 14 |
struct A; |
| 15 |
struct B { int b; double b2; }; |
| 16 |
struct C : virtual B { int c; }; |
| 17 |
struct D {}; |
| 18 |
struct E {}; |
| 19 |
struct F : public B, D, E {}; |
| 20 |
struct G : public D, E { int g; }; |
| 21 |
struct H {}; |
| 22 |
struct I : public G, H {}; |
| 23 |
struct J { int j1; private: int j2; public: int j3; }; |
| 24 |
struct K : public J {}; |
| 25 |
struct L : public B, D, E {}; |
| 26 |
struct M { D d [[no_unique_address]]; E e [[no_unique_address]]; int f; }; |
| 27 |
union U { int a; double b; long long c; }; |
| 28 |
struct V { union { int a; long b; }; int c; }; |
| 29 |
union X { int a; union { short b; long c; }; long long d; }; |
| 30 |
struct Y { void foo () {} }; |
| 31 |
union Z { int a; private: int b; protected: int c; public: int d; }; |
| 32 |
|
| 33 |
int |
| 34 |
main () |
| 35 |
{ |
| 36 |
auto t1 = &B::b; |
| 37 |
if (!std::is_pointer_interconvertible_with_class (t1)) |
| 38 |
__builtin_abort (); |
| 39 |
auto t2 = &B::b2; |
| 40 |
if (std::is_pointer_interconvertible_with_class (t2)) |
| 41 |
__builtin_abort (); |
| 42 |
auto t3 = &C::b; |
| 43 |
if (!std::is_pointer_interconvertible_with_class (t3)) |
| 44 |
__builtin_abort (); |
| 45 |
auto t4 = &F::b; |
| 46 |
if (!std::is_pointer_interconvertible_with_class (t4)) |
| 47 |
__builtin_abort (); |
| 48 |
int F::*t5 = &F::b; |
| 49 |
if (!std::is_pointer_interconvertible_with_class (t5)) |
| 50 |
__builtin_abort (); |
| 51 |
auto t6 = &G::g; |
| 52 |
if (!std::is_pointer_interconvertible_with_class (t6)) |
| 53 |
__builtin_abort (); |
| 54 |
int G::*t7 = &G::g; |
| 55 |
if (!std::is_pointer_interconvertible_with_class (t7)) |
| 56 |
__builtin_abort (); |
| 57 |
auto t8 = &I::g; |
| 58 |
if (!std::is_pointer_interconvertible_with_class (t8)) |
| 59 |
__builtin_abort (); |
| 60 |
int I::*t9 = &I::g; |
| 61 |
if (!std::is_pointer_interconvertible_with_class (t9)) |
| 62 |
__builtin_abort (); |
| 63 |
auto t10 = &J::j1; |
| 64 |
if (std::is_pointer_interconvertible_with_class (t10)) |
| 65 |
__builtin_abort (); |
| 66 |
auto t11 = &J::j3; |
| 67 |
if (std::is_pointer_interconvertible_with_class (t11)) |
| 68 |
__builtin_abort (); |
| 69 |
auto t12 = &K::j1; |
| 70 |
if (std::is_pointer_interconvertible_with_class (t12)) |
| 71 |
__builtin_abort (); |
| 72 |
auto t13 = &K::j3; |
| 73 |
if (std::is_pointer_interconvertible_with_class (t13)) |
| 74 |
__builtin_abort (); |
| 75 |
auto t14 = &L::b; |
| 76 |
if (!std::is_pointer_interconvertible_with_class (t14)) |
| 77 |
__builtin_abort (); |
| 78 |
int L::*t15 = &L::b; |
| 79 |
if (!std::is_pointer_interconvertible_with_class (t15)) |
| 80 |
__builtin_abort (); |
| 81 |
auto t16 = &L::b; |
| 82 |
if (!std::is_pointer_interconvertible_with_class (t16)) |
| 83 |
__builtin_abort (); |
| 84 |
auto t17 = &M::d; |
| 85 |
if (!std::is_pointer_interconvertible_with_class (t17)) |
| 86 |
__builtin_abort (); |
| 87 |
auto t18 = &M::e; |
| 88 |
if (std::is_pointer_interconvertible_with_class (t18)) |
| 89 |
__builtin_abort (); |
| 90 |
auto t19 = &M::f; |
| 91 |
if (std::is_pointer_interconvertible_with_class (t19)) |
| 92 |
__builtin_abort (); |
| 93 |
auto t20 = &U::a; |
| 94 |
if (!std::is_pointer_interconvertible_with_class (t20)) |
| 95 |
__builtin_abort (); |
| 96 |
auto t21 = &U::b; |
| 97 |
if (!std::is_pointer_interconvertible_with_class (t21)) |
| 98 |
__builtin_abort (); |
| 99 |
auto t22 = &U::c; |
| 100 |
if (!std::is_pointer_interconvertible_with_class (t22)) |
| 101 |
__builtin_abort (); |
| 102 |
auto t23 = &V::a; |
| 103 |
if (!std::is_pointer_interconvertible_with_class (t23)) |
| 104 |
__builtin_abort (); |
| 105 |
auto t24 = &V::b; |
| 106 |
if (!std::is_pointer_interconvertible_with_class (t24)) |
| 107 |
__builtin_abort (); |
| 108 |
auto t25 = &V::c; |
| 109 |
if (std::is_pointer_interconvertible_with_class (t25)) |
| 110 |
__builtin_abort (); |
| 111 |
auto t26 = &X::a; |
| 112 |
if (!std::is_pointer_interconvertible_with_class (t26)) |
| 113 |
__builtin_abort (); |
| 114 |
auto t27 = &X::b; |
| 115 |
if (!std::is_pointer_interconvertible_with_class (t27)) |
| 116 |
__builtin_abort (); |
| 117 |
auto t28 = &X::c; |
| 118 |
if (!std::is_pointer_interconvertible_with_class (t28)) |
| 119 |
__builtin_abort (); |
| 120 |
auto t29 = &X::d; |
| 121 |
if (!std::is_pointer_interconvertible_with_class (t29)) |
| 122 |
__builtin_abort (); |
| 123 |
auto t30 = (int B::*) nullptr; |
| 124 |
if (std::is_pointer_interconvertible_with_class (t30)) |
| 125 |
__builtin_abort (); |
| 126 |
auto t31 = &Y::foo; |
| 127 |
if (std::is_pointer_interconvertible_with_class (t31)) |
| 128 |
__builtin_abort (); |
| 129 |
auto t32 = &Z::a; |
| 130 |
if (!std::is_pointer_interconvertible_with_class (t32)) |
| 131 |
__builtin_abort (); |
| 132 |
auto t33 = &Z::d; |
| 133 |
if (!std::is_pointer_interconvertible_with_class (t33)) |
| 134 |
__builtin_abort (); |
| 135 |
} |