[clang] [Clang] allow restrict qualifier for array types with pointer types as element types (PR #120896)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 31 07:05:41 PST 2025


================
@@ -9,20 +9,20 @@ typedef int (*T)[2];
 restrict T x;
 
 typedef int *S[2];
-restrict S y; // expected-error {{restrict requires a pointer or reference ('S' (aka 'int *[2]') is invalid)}}
-
-
+restrict S y;
----------------
AaronBallman wrote:

Can you also add a test for multidimensional arrays, like:
```
typedef int *S[2][2];
restrict S y;
```
and (this should already work because it's adding the restrict to a pointer to an array):
```
typedef int (*S)[2];
restrict S y;
```
and finally, can you add some type verification tests like (for each of the test cases):
```
static_assert(_Generic(typeof(y), int * restrict[2]: 1, default : 0));
```

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


More information about the cfe-commits mailing list