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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 28 11:09:39 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:

It's basically a holdover from UNIX; files were a series of lines which ended with a newline character, so no newline at the end of the source file can trip up some tools (I think most tools these days handle everything reasonably well, though).

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


More information about the cfe-commits mailing list