[clang] [Clang] [C23] Fix typeof_unqual for qualified array types (PR #92767)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu May 30 13:18:44 PDT 2024


================
@@ -92,3 +92,43 @@ extern __attribute__((address_space(0))) int type_attr_test_2;          // expec
 void invalid_param_fn(__attribute__((address_space(1))) int i); // expected-error {{parameter may not be qualified with an address space}}
 typeof(invalid_param_fn) invalid_param_1;
 typeof_unqual(invalid_param_fn) invalid_param_2;
+
+// Ensure restrict is stripped
+extern int *restrict p1;
+extern int *p2;
+extern typeof(p1) p1;
+extern typeof_unqual(p1) p2;
+
+// Ensure array qualifications are removed
+extern const int aci[2];
+extern const int acii[2][2];
+extern int ai[2];
+extern int aii[2][2];
+extern typeof(aci) aci;
+extern typeof_unqual(aci) ai;
+extern typeof(acii) acii;
+extern typeof_unqual(acii) aii;
----------------
AaronBallman wrote:

Curiously, this is different from the results in GCC: https://godbolt.org/z/5rczxdGKn

Based on my understanding of "An array and its element type are always considered to be identically qualified.", I think GCC's behavior is incorrect, but it would be good to file an issue with them to let them know to ensure we agree.

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


More information about the cfe-commits mailing list