[clang] [clang] Ensure correct copying of records with authenticated fields (PR #136783)

Oliver Hunt via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 24 11:52:01 PDT 2025


================
@@ -103,3 +103,46 @@ static_assert(_Generic(typeof(overload_func(&ptr0)), int : 1, default : 0));
 static_assert(_Generic(typeof(overload_func(&valid0)), float : 1, default : 0));
 
 void func(int array[__ptrauth(VALID_DATA_KEY) 10]); // expected-error {{'__ptrauth' qualifier only applies to pointer types; 'int[10]' is invalid}}
+
+struct S0 { // expected-note 4 {{struct S0' has subobjects that are non-trivial to copy}}
+  intp __ptrauth(1, 1, 50) f0; // expected-note 4 {{f0 has type '__ptrauth(1,1,50) intp' (aka 'int *__ptrauth(1,1,50)') that is non-trivial to copy}}
+};
+
+union U0 { // expected-note 4 {{union U0' has subobjects that are non-trivial to copy}}
+  struct S0 s0;
+};
+
+struct S1 {
+  intp __ptrauth(1, 0, 50) f0;
+};
+
+union U1 {
+  struct S1 s1;
+};
+
+union U2 { // expected-note 2 {{union U2' has subobjects that are non-trivial to copy}}
+  intp __ptrauth(1, 1, 50) f0; // expected-note 2 {{f0 has type '__ptrauth(1,1,50) intp' (aka 'int *__ptrauth(1,1,50)') that is non-trivial to copy}}
+  intp __ptrauth(1, 0, 50) f1;
+};
+
+// Test for r353556.
----------------
ojhunt wrote:

Hmmmmm, I forget how old the pointer auth code is :D

https://github.com/llvm/llvm-project/pull/136783


More information about the cfe-commits mailing list