Origami404 added a comment.

>   int foo(void);
>   
>   void bar(int a, int b[*]); // variable length array used, correct
>   void bar(int a, int b[a]) { variable length array used, correct
>     int x[foo()]; // variable length array that may require stack allocation 
> used, correct
>   
>     (void)sizeof(int[foo()]); // variable length array that may require stack 
> allocation used, incorrect and the diagnostic triggers twice
>   
>     int (*y)[foo()]; // variable length array that may require stack 
> allocation used, incorrect, this is a pointer to a VLA
>   }

Thanks to ballman's example here, it remains me that when non-LCE appears as an 
array index in a variable declaration, it is still possible to be a part of a 
pointer/function prototype instead of a VLA. Classifying different VLA usages 
requires more information about the declaration.

The old VLA checking implements just insert checking for the location in array 
type construction when a non-ICE is used as the array's length. And it assumes 
that only one error or warning could be produced by one VLA usage. So the old 
method seems hard to be extended to support the new checking on VLAs.

I plan to throw away the old method here, trying to use "eval functions" on AST 
of declarations or LLVM IR to classify different kinds of VLAs.

Since I am preparing for several final examinations next week, I will try to 
give a new implementation in about a week. And in advance, sorry for my late 
response next week.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137343

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

Reply via email to