c++: Fix cast to pointer to VLA.
authorJason Merrill <jason@redhat.com>
Sat, 1 Feb 2020 02:59:48 +0000 (21:59 -0500)
committerJason Merrill <jason@redhat.com>
Mon, 3 Feb 2020 14:21:06 +0000 (09:21 -0500)
commit3539fc1317267b30eb7c4ad48d52f4e46b3a198a
tree7bb9a2798fc1b9e3a94539e44b31f861b3f99194
parent44f77a6dea2f312ee1743f3dde465c1b8453ee13
c++: Fix cast to pointer to VLA.

The C front-end fixed this issue in r257620 by adding a DECL_EXPR from
grokdeclarator.  We don't have an easy way to do that in the C++ front-end,
but it works fine to create and prepend a DECL_EXPR when we are genericizing
the NOP_EXPR for the cast.

The C patch wraps the DECL_EXPR in a BIND_EXPR, but that seems unnecessary
in C++; this is just a hook to run gimplify_type_sizes, we aren't actually
declaring anything that we need to worry about scoping for.

PR c++/88256
* cp-gimplify.c (predeclare_vla): New.
(cp_genericize_r) [NOP_EXPR]: Call it.
gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/testsuite/c-c++-common/pr84305.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/compile/pr84305.c [deleted file]