|
| 1 | +// RUN: %clang_cc1 -triple arm64-apple-ios -std=c++20 -fptrauth-calls -fptrauth-intrinsics -verify -fsyntax-only %s |
| 2 | +// RUN: %clang_cc1 -triple aarch64-linux-gnu -std=c++20 -fptrauth-calls -fptrauth-intrinsics -verify -fsyntax-only %s |
| 3 | +// expected-no-diagnostics |
| 4 | + |
| 5 | +#define AQ __ptrauth(1,1,50) |
| 6 | +#define IQ __ptrauth(1,0,50) |
| 7 | +#define AA [[clang::ptrauth_vtable_pointer(process_independent,address_discrimination,no_extra_discrimination)]] |
| 8 | +#define IA [[clang::ptrauth_vtable_pointer(process_independent,no_address_discrimination,type_discrimination)]] |
| 9 | +#define PA [[clang::ptrauth_vtable_pointer(process_dependent,no_address_discrimination,no_extra_discrimination)]] |
| 10 | + |
| 11 | +template <class T> |
| 12 | +struct Holder { |
| 13 | + T t_; |
| 14 | + bool operator==(const Holder&) const = default; |
| 15 | +}; |
| 16 | + |
| 17 | +struct S1 { |
| 18 | + int * AQ p_; |
| 19 | + void *payload_; |
| 20 | + bool operator==(const S1&) const = default; |
| 21 | +}; |
| 22 | +static_assert(__is_trivially_constructible(S1)); |
| 23 | +static_assert(!__is_trivially_constructible(S1, const S1&)); |
| 24 | +static_assert(!__is_trivially_assignable(S1, const S1&)); |
| 25 | +static_assert(__is_trivially_destructible(S1)); |
| 26 | +static_assert(!__is_trivially_copyable(S1)); |
| 27 | +static_assert(!__is_trivially_relocatable(S1)); |
| 28 | +static_assert(!__is_trivially_equality_comparable(S1)); |
| 29 | + |
| 30 | +static_assert(__is_trivially_constructible(Holder<S1>)); |
| 31 | +static_assert(!__is_trivially_constructible(Holder<S1>, const Holder<S1>&)); |
| 32 | +static_assert(!__is_trivially_assignable(Holder<S1>, const Holder<S1>&)); |
| 33 | +static_assert(__is_trivially_destructible(Holder<S1>)); |
| 34 | +static_assert(!__is_trivially_copyable(Holder<S1>)); |
| 35 | +static_assert(!__is_trivially_relocatable(Holder<S1>)); |
| 36 | +static_assert(!__is_trivially_equality_comparable(Holder<S1>)); |
| 37 | + |
| 38 | +struct S2 { |
| 39 | + int * IQ p_; |
| 40 | + void *payload_; |
| 41 | + bool operator==(const S2&) const = default; |
| 42 | +}; |
| 43 | +static_assert(__is_trivially_constructible(S2)); |
| 44 | +static_assert(__is_trivially_constructible(S2, const S2&)); |
| 45 | +static_assert(__is_trivially_assignable(S2, const S2&)); |
| 46 | +static_assert(__is_trivially_destructible(S2)); |
| 47 | +static_assert(__is_trivially_copyable(S2)); |
| 48 | +static_assert(__is_trivially_relocatable(S2)); |
| 49 | +static_assert(__is_trivially_equality_comparable(S2)); |
| 50 | + |
| 51 | +static_assert(__is_trivially_constructible(Holder<S2>)); |
| 52 | +static_assert(__is_trivially_constructible(Holder<S2>, const Holder<S2>&)); |
| 53 | +static_assert(__is_trivially_assignable(Holder<S2>, const Holder<S2>&)); |
| 54 | +static_assert(__is_trivially_destructible(Holder<S2>)); |
| 55 | +static_assert(__is_trivially_copyable(Holder<S2>)); |
| 56 | +static_assert(__is_trivially_relocatable(Holder<S2>)); |
| 57 | +static_assert(__is_trivially_equality_comparable(Holder<S2>)); |
| 58 | + |
| 59 | +struct AA S3 { |
| 60 | + virtual void f(); |
| 61 | + void *payload_; |
| 62 | + bool operator==(const S3&) const = default; |
| 63 | +}; |
| 64 | + |
| 65 | +static_assert(!__is_trivially_constructible(S3)); |
| 66 | +static_assert(!__is_trivially_constructible(S3, const S3&)); |
| 67 | +static_assert(!__is_trivially_assignable(S3, const S3&)); |
| 68 | +static_assert(__is_trivially_destructible(S3)); |
| 69 | +static_assert(!__is_trivially_copyable(S3)); |
| 70 | +static_assert(!__is_trivially_relocatable(S3)); |
| 71 | +static_assert(!__is_trivially_equality_comparable(S3)); |
| 72 | + |
| 73 | +static_assert(!__is_trivially_constructible(Holder<S3>)); |
| 74 | +static_assert(!__is_trivially_constructible(Holder<S3>, const Holder<S3>&)); |
| 75 | +static_assert(!__is_trivially_assignable(Holder<S3>, const Holder<S3>&)); |
| 76 | +static_assert(__is_trivially_destructible(Holder<S3>)); |
| 77 | +static_assert(!__is_trivially_copyable(Holder<S3>)); |
| 78 | +static_assert(!__is_trivially_relocatable(Holder<S3>)); |
| 79 | +static_assert(!__is_trivially_equality_comparable(Holder<S3>)); |
| 80 | + |
| 81 | +struct IA S4 { |
| 82 | + virtual void f(); |
| 83 | + void *payload_; |
| 84 | + bool operator==(const S4&) const = default; |
| 85 | +}; |
| 86 | + |
| 87 | +static_assert(!__is_trivially_constructible(S4)); |
| 88 | +static_assert(!__is_trivially_constructible(S4, const S4&)); |
| 89 | +static_assert(!__is_trivially_assignable(S4, const S4&)); |
| 90 | +static_assert(__is_trivially_destructible(S4)); |
| 91 | +static_assert(!__is_trivially_copyable(S4)); |
| 92 | +static_assert(!__is_trivially_relocatable(S4)); |
| 93 | +static_assert(!__is_trivially_equality_comparable(S4)); |
| 94 | + |
| 95 | +static_assert(!__is_trivially_constructible(Holder<S4>)); |
| 96 | +static_assert(!__is_trivially_constructible(Holder<S4>, const Holder<S4>&)); |
| 97 | +static_assert(!__is_trivially_assignable(Holder<S4>, const Holder<S4>&)); |
| 98 | +static_assert(__is_trivially_destructible(Holder<S4>)); |
| 99 | +static_assert(!__is_trivially_copyable(Holder<S4>)); |
| 100 | +static_assert(!__is_trivially_relocatable(Holder<S4>)); |
| 101 | +static_assert(!__is_trivially_equality_comparable(Holder<S4>)); |
| 102 | + |
| 103 | +struct PA S5 { |
| 104 | + virtual void f(); |
| 105 | + void *payload_; |
| 106 | + bool operator==(const S5&) const = default; |
| 107 | +}; |
| 108 | + |
| 109 | +static_assert(!__is_trivially_constructible(S5)); |
| 110 | +static_assert(!__is_trivially_constructible(S5, const S5&)); |
| 111 | +static_assert(!__is_trivially_assignable(S5, const S5&)); |
| 112 | +static_assert(__is_trivially_destructible(S5)); |
| 113 | +static_assert(!__is_trivially_copyable(S5)); |
| 114 | +static_assert(!__is_trivially_relocatable(S5)); |
| 115 | +static_assert(!__is_trivially_equality_comparable(S5)); |
| 116 | + |
| 117 | +static_assert(!__is_trivially_constructible(Holder<S5>)); |
| 118 | +static_assert(!__is_trivially_constructible(Holder<S5>, const Holder<S5>&)); |
| 119 | +static_assert(!__is_trivially_assignable(Holder<S5>, const Holder<S5>&)); |
| 120 | +static_assert(__is_trivially_destructible(Holder<S5>)); |
| 121 | +static_assert(!__is_trivially_copyable(Holder<S5>)); |
| 122 | +static_assert(!__is_trivially_relocatable(Holder<S5>)); |
| 123 | +static_assert(!__is_trivially_equality_comparable(Holder<S5>)); |
0 commit comments