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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 7 09:05:53 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:

> To clarify my earlier point: -fexperimental-late-parse-attributes is intended to change parsing behavior within attributes (as the flag name suggests), not array sizes — and the same applies to -fbounds-safety. The reason these dialects are relevant to this PR, however, is that what we learn here may inform decisions about them down the road — for example, whether this name lookup behavior remains experimental and gets superseded by whatever approach array sizes end up taking, or whether it evolves into something more broadly applicable to the core language.

But it's the same two approaches whether we're diagnosing arrays or attributes, right? e.g.,
```
constexpr int n = 10; // #first
void func(
  int * __counted_by(n) arr,  // expected-warning: use of 'n' is potentially confusing \
                                 expected-note@#first: 'n' refers to this declaration \
                                 expected-ntoe@#second: but could potentially be confused for this 'n'
  int n // #second
);
```
as opposed to the changes meaning form:
```
constexpr int n = 10; // #second
void func(
  int * __counted_by(n) arr, // #first
  int n  // expected-warning: declaration of 'n' changes meaning \
            expected-note@#first: this use of 'n' refers to the parameter declaration \
            expected-note@#second: not this declaration of 'n'
);
```

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


More information about the cfe-commits mailing list