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

Matheus Izvekov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 30 15:15:49 PDT 2022


mizvekov added a comment.

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

> As a practical matter, there isn't any reason to force variably modified parameters to make a function variably modified.  The types of parameters aren't visible in the caller of a function; we only check the compatibility for calls.
>
> Trying to treat `void (*)(int, int *)` as variably modified would have additional complications, in that clang would internally need to have two canonical types for `void (*)(int, int *)`: one variably modified, one not variably modified.

I have been thinking about this problem for different reasons.

I wonder if the right solution here is to just change AdjustedType so that it desugars to the OriginalType instead of the AdjustedType, but keep the latter as the canonical type.
And not bother storing a separate QualType fot the AdjustedType.

That way, after a decay, the as-written type could be VM, but not the canonical type.

Similarly with `AttributedType` vis EquivalentType and ModifiedType.

We would lose though the nice property that a single step desugar always produces the same type.

I wonder how radical a change this would be for the users.


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