efriedma added a comment.

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

>> 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`.

The type of parameter array after promotion (which is the type that matters for 
almost any purpose), is `int*`.  That isn't variably modified.  And the 
function type is just `void(int,int*)`; there's no way we can possibly treat 
that as variably modified.

If you wrote, say `void func(int n, int array[n][n])`, then array is variably 
modified.  "func" is still not variably modified, I think?  "array" is not part 
of the "nested sequence of declarators", despite the fact that the parameter 
list contains a variably modified type.  At least, that's clang's current 
interpretation of the rules.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132952

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to