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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 1 11:58:41 PDT 2022


aaron.ballman added a comment.

In D132952#3761874 <https://reviews.llvm.org/D132952#3761874>, @aaron.ballman wrote:

> I'll ask on the WG14 reflectors to see if I'm interpreting the variably modified type specification wrong or not.

There's some agreement that the existing words could stand to be improved; others on the committee had similar questions and concerns as we had. The sentiment expressed so far has been that a function type cannot be a VM type except perhaps (uselessly) as part of its return type. If a function were to be a VM type, it couldn't be declared at file scope, and that would be a bit... silly. One thing I missed when investigating this was C2x 6.2.5p23:

"A function type describes a function with specified return type. A function type is characterized by its return type and the number and types of its parameters. A function type is said to be derived from its return type, and if its return type is T, the function type is sometimes called "function returning T". The construction of a function type from a return type is called "function type derivation".

This is kind of a hand-wavey way of saying that the function's return type is part of the sequence of declarators for the full declarator, but the parameter list is not, because the function type is derived from the return type alone. Maybe.

All this said, there was a little bit of sentiment expressed that it would be nice if C would allow functions to be a VM type so that the type system doesn't lose important semantic information, but that's a big project and who knows whether anyone will try to take it on or not.

Unwinding the stack a bit back to what got us on this discussion: I think I agree with Eli that we're probably diagnosing VLAs from the wrong place instead of modeling them wrong in the type system.


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