| 1 |
// RUN: %clang_cc1 -triple arm64 -fptrauth-calls -fptrauth-intrinsics -std=c++26 -verify %s |
| 2 |
|
| 3 |
// This test intentionally does not enable the global address discrimination |
| 4 |
// of vtable pointers. This lets us configure them with different schemas |
| 5 |
// and verify that we're correctly tracking the existence of address discrimination |
| 6 |
|
| 7 |
// expected-no-diagnostics |
| 8 |
|
| 9 |
struct NonAddressDiscPtrauth { |
| 10 |
void * __ptrauth(1, 0, 1234) p; |
| 11 |
}; |
| 12 |
|
| 13 |
static_assert(__builtin_is_cpp_trivially_relocatable(NonAddressDiscPtrauth)); |
| 14 |
|
| 15 |
struct AddressDiscPtrauth { |
| 16 |
void * __ptrauth(1, 1, 1234) p; |
| 17 |
}; |
| 18 |
|
| 19 |
static_assert(!__builtin_is_cpp_trivially_relocatable(AddressDiscPtrauth)); |
| 20 |
|
| 21 |
struct MultipleBaseClasses : NonAddressDiscPtrauth, AddressDiscPtrauth { |
| 22 |
|
| 23 |
}; |
| 24 |
|
| 25 |
static_assert(!__builtin_is_cpp_trivially_relocatable(MultipleBaseClasses)); |
| 26 |
|
| 27 |
struct MultipleMembers1 { |
| 28 |
NonAddressDiscPtrauth field0; |
| 29 |
AddressDiscPtrauth field1; |
| 30 |
}; |
| 31 |
|
| 32 |
static_assert(!__builtin_is_cpp_trivially_relocatable(MultipleMembers1)); |
| 33 |
|
| 34 |
struct MultipleMembers2 { |
| 35 |
NonAddressDiscPtrauth field0; |
| 36 |
NonAddressDiscPtrauth field1; |
| 37 |
}; |
| 38 |
|
| 39 |
static_assert(__builtin_is_cpp_trivially_relocatable(MultipleMembers2)); |
| 40 |
|
| 41 |
struct UnionOfPtrauth { |
| 42 |
union { |
| 43 |
NonAddressDiscPtrauth field0; |
| 44 |
AddressDiscPtrauth field1; |
| 45 |
} u; |
| 46 |
}; |
| 47 |
|
| 48 |
static_assert(!__builtin_is_cpp_trivially_relocatable(UnionOfPtrauth)); |
| 49 |
|
| 50 |
struct UnionOfNonAddressDiscriminatedPtrauth { |
| 51 |
union { |
| 52 |
NonAddressDiscPtrauth p; |
| 53 |
int i; |
| 54 |
} u; |
| 55 |
}; |
| 56 |
|
| 57 |
static_assert(__builtin_is_cpp_trivially_relocatable(UnionOfNonAddressDiscriminatedPtrauth)); |
| 58 |
|
| 59 |
struct UnionOfAddressDisriminatedPtrauth { |
| 60 |
union { |
| 61 |
AddressDiscPtrauth p; |
| 62 |
int i; |
| 63 |
} u; |
| 64 |
}; |
| 65 |
|
| 66 |
static_assert(!__builtin_is_cpp_trivially_relocatable(UnionOfAddressDisriminatedPtrauth)); |