[clang] Diagnose potential size confusion with VLA params [contd.] (PR #181550)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 13 05:54:02 PDT 2026


================
@@ -1114,7 +1114,8 @@ def VexingParse : DiagGroup<"vexing-parse">;
 def VLAUseStaticAssert : DiagGroup<"vla-extension-static-assert">;
 def VLACxxExtension : DiagGroup<"vla-cxx-extension", [VLAUseStaticAssert]>;
 def VLAExtension : DiagGroup<"vla-extension", [VLACxxExtension]>;
-def VLA : DiagGroup<"vla", [VLAExtension]>;
+def VLASizeConfusion : DiagGroup<"vla-potential-size-confusion">;
----------------
AaronBallman wrote:

I think we would like (not all in one patch):

* Introduce `-Wname-confusion-parameter-array-sizes` which only diagnoses confusing use of names within the size expression of an array in a parameter list.
* Possibly: introduce `-Wname-confusion-attr` which only diagnoses confusing use of names within the argument list of an attribute, regardless of where the attribute lives (parameter lists, structure member lists being the primary concerns at the moment). If we do this, then add `-Wname-confusion` at the same time so there's one parent group for both diagnostics.
* Introduce `-Wchanges-meaning` for these scenarios in C++ or when `-fexperimental-late-parse-attributes` (or `-fbounds-safety`?) is enabled.

So I think the "further down the road" work is actually the `-Wname-confusion-attr` part and not the `-Wchanges-meaning`, though I think `-Wchanges-meaning` should be handled in a separate PR.

Do you agree with that plan @rapidsna?

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


More information about the cfe-commits mailing list