================
@@ -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;
----------------
AmrDeveloper wrote:

I think the PR title did not contain the full details, but we need the type of 
the Subscript expression to be VLA

```c++
if (const VariableArrayType *vla =
    getContext().getAsVariableArrayType(e->getType())) {
```

For the expected code, we already support it because the result of the index 
expr will be int

https://github.com/llvm/llvm-project/blob/0a69bccce9ec985ee875154b0a0689be1facc0df/clang/test/CIR/CodeGen/vla.c#L285-L288


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

I agree it's looks odd :D, I was checking which code from OGCG we support and 
which part is NYI and i found this interesting cose


https://github.com/llvm/llvm-project/blob/0a69bccce9ec985ee875154b0a0689be1facc0df/clang/test/CodeGen/vla.c#L167-L187


https://github.com/llvm/llvm-project/pull/175370
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to