[clang] [clang] Improve diagnostics with incompatible VLA types (PR #101261)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 31 10:20:09 PDT 2024


================
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void func(int n) {
+    int grp[n][n];
+    int (*ptr)[n];
+
+    for (int i = 0; i < n; i++)
+        ptr = &grp[i]; // expected-error {{incompatible assignment of pointers of variable-length array type 'int (*)[n]'; consider using a typedef to use the same variable-length array type for both operands}}
+}
----------------
AaronBallman wrote:

You should add a newline to the end of the test file. We're missing some additional test coverage, but we can handle that once we know more about what direction we want to take the fix.

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


More information about the cfe-commits mailing list