[clang] [PAC] Add support for __ptrauth type qualifier (PR #100830)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 5 07:00:34 PST 2025
================
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios -fsyntax-only -verify -fptrauth-intrinsics -std=c++11 %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -fsyntax-only -verify -fptrauth-intrinsics -std=c++11 %s
+
+template <typename T> struct G {
+ T __ptrauth(0,0,1234) test;
+ // expected-error at -1 2 {{type '__ptrauth(0,0,1234) T' is already __ptrauth-qualified}}
+};
+
+template <typename T> struct Indirect {
+ G<T> layers;
+ // expected-note at -1{{in instantiation of template class 'G<void *__ptrauth(0,0,1235)>' requested here}}
+ // expected-note at -2{{in instantiation of template class 'G<void *__ptrauth(0,0,1234)>' requested here}}
+};
+
+void f3() {
+ Indirect<void* __ptrauth(0,0,1234)> one;
+ // expected-note at -1{{in instantiation of template class 'Indirect<void *__ptrauth(0,0,1234)>' requested here}}
+ Indirect<void* __ptrauth(0,0,1235)> two;
+ // expected-note at -1{{in instantiation of template class 'Indirect<void *__ptrauth(0,0,1235)>' requested here}}
+ Indirect<void*> three;
+}
----------------
AaronBallman wrote:
Other template test cases to consider: deduction on parameters, e.g.,
```
template <int A, int B, int C>
int func(void * __ptrauth(A, B, C) ptr) {
return A + B + C;
}
constinit void * __ptrauth(1, 2, 3) p = nullptr;
static_assert(foo(p) == 6);
```
Also should test SFINAE behavior.
https://github.com/llvm/llvm-project/pull/100830
More information about the cfe-commits
mailing list