c++: Tweak predeclare_vla.
authorJason Merrill <jason@redhat.com>
Sat, 6 Jun 2020 04:07:21 +0000 (00:07 -0400)
committerJason Merrill <jason@redhat.com>
Tue, 9 Jun 2020 16:05:50 +0000 (12:05 -0400)
We only need to predeclare a VLA type if it's wrapped in a pointer type;
otherwise gimplify_type_sizes will handle it.

gcc/cp/ChangeLog:

PR c++/95552
* cp-gimplify.c (predeclare_vla): Only predeclare a VLA if it's
wrapped in a pointer type.

gcc/cp/cp-gimplify.c

index e8fbc300fdaa8c8565b33a3610cb6629fa82c885..0e949e29c5c62b0ddd4ae5f459448a09d19a9cb7 100644 (file)
@@ -1205,7 +1205,8 @@ predeclare_vla (tree expr)
        return expr;
       vla = TREE_TYPE (vla);
     }
-  if (TYPE_NAME (vla) || !variably_modified_type_p (vla, NULL_TREE))
+  if (vla == type || TYPE_NAME (vla)
+      || !variably_modified_type_p (vla, NULL_TREE))
     return expr;
 
   tree decl = build_decl (input_location, TYPE_DECL, NULL_TREE, vla);