[clang] [CIR] SubscriptExpr for VariableLengthArray (PR #175370)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 12 13:26:13 PST 2026


================
@@ -339,3 +339,57 @@ int f5(unsigned long len) {
 // OGCG:   %[[STACK_RESTORE_PTR:.*]] = load ptr, ptr %[[SAVED_STACK]]
 // OGCG:   call void @llvm.stackrestore.p0(ptr %[[STACK_RESTORE_PTR]])
 // OGCG:   ret i32 %[[ARR_VAL]]
+
+void vla_subscript_expr() {
+  int **a;
+  unsigned long n = 5;
+  (int (**)[n]){&a}[0][1][5] = 0;
----------------
andykaylor wrote:

This is an odd choice for the test. Where did this come from?

I was expecting something more like this:

```
int f0(int x) {
  int vla[x];
  return vla[x-1];
}
```

Having a multi-dimension array test is good, but I don't understand the reason for the arbitrary cast expression.

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


More information about the cfe-commits mailing list