[PATCH] D132952: [Sema] disable -Wvla for function array parameters
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 31 11:41:13 PDT 2022
aaron.ballman 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.
There are constraints in C based on whether something is or isn't a variably modified type, so I think there is a reason to make sure we're correct here. For example:
// All at file scope
int n = 100;
void func(int array[n++]);
typedef typeof(func) other_func;
C2x 6.7.8p2: "If a typedef name specifies a variably modified type then it shall have block scope." Even more interesting is C2x 6.7.2.5p4 (typeof, which is new in C2x): "If the type of the operand is a variably modified type, the operand is evaluated; otherwise the operand is not evaluated."
> 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.
>
> So if there's a disagreement between clang and the standard, I'd rather just try to fix the standard.
I'll ask on the WG14 reflectors to see if I'm interpreting the variably modified type specification wrong or not.
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