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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 30 11:54:42 PDT 2022


aaron.ballman added a comment.

In D132952#3759109 <https://reviews.llvm.org/D132952#3759109>, @efriedma wrote:

>> We have the VariableArrayType to represent a VLA type and I think we're using that type when we should be using a variably modified type
>
> The clang AST for function signatures encodes two types: the type as written, and the type after promotion.  Semantic analysis always uses the type after promotion, but the type as written is useful if you're trying to do source rewriting, or something like that.

Agreed; we need the type as written for `-ast-print` support, as well as AST matchers, etc.

> We could theoretically mess with the AST representation somehow, but I don't see any compelling reason to.  We probably just want to emit the warn_vla_used diagnostic somewhere else.

Yeah, re-reading the C standard, I think I got VM types slightly wrong. Consider:

  void func(int n, int array[n]);

`array` is a VLA (C2x 6.7.6.2p4) before pointer adjustment (C2x 6.7.6.3p6), which makes `func` a VM type (C2x 6.7.6p3), not `array`.


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