[PATCH] D132952: [Sema] disable -Wvla for function array parameters

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 9 11:01:46 PDT 2022


aaron.ballman added a comment.

In D132952#3773469 <https://reviews.llvm.org/D132952#3773469>, @inclyc wrote:

>> Yeah, that's a different way of delineating than I was thinking originally and it's worth more thought. I was thinking the separation would be "this is a VLA" (for people who want to avoid all VLA stack allocations due to the security concerns) and "this is a portability concern" (for people who want to port to older language standards, C++, other compilers).
>
> I think it is a good idea to separate `-Wvla` into `-Wvla-portability`(warnings on portability) and `-Wvla-stack` (warnings on stack allocations, security issue). Report `-Wvla-portability` if compilers implementations in practice don't support any `vla` syntax especially in C89 mode and report `-Wvla-stack` if it causes stack allocations.

This is largely the same conclusion I think I've come to as well. Add two new warning groups (we can bikeshed the names later): `-Wvla-portability` and `-Wvla-stack-allocation` grouped under the existing `-Wvla`. The behavior of `-Wvla` won't change, but users can opt into the kind of specific diagnostic they want. `void func(int n, int array[n]);` would trigger `-Wvla-portability` but not `-Wvla-stack-allocation`, and `void func(int n) { int array[n]; }` would trigger both diagnostics (though we could debate having it skip the `-Wvla-portability` warning whenever giving any other "you're using a VLA" kind of warning). @efriedma are you on board with that plan as well?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132952/new/

https://reviews.llvm.org/D132952



More information about the cfe-commits mailing list