c++: assignment, aggregate, array [PR104300]
authorJason Merrill <jason@redhat.com>
Wed, 2 Feb 2022 23:36:41 +0000 (18:36 -0500)
committerJason Merrill <jason@redhat.com>
Sat, 5 Feb 2022 05:56:05 +0000 (00:56 -0500)
commit119cea98f664764cce04963243c39c8f6d797d33
tree1a19f7038ed4bbbf8733db6bf1d7d977068e6741
parent0ef416e7edc4c66a06a3c05025720dfc98cf07f5
c++: assignment, aggregate, array [PR104300]

The PR92385 fix meant that we see more VEC_INIT_EXPR outside of INIT_EXPR;
in such cases, we need to wrap them in TARGET_EXPR.  I previously fixed
that in build_array_copy; we also need it in process_init_constructor.
After fixing that, I needed to adjust a few places to recognize the
VEC_INIT_EXPR even inside a TARGET_EXPR.  And prevent cp_fully_fold_init
from lowering VEC_INIT_EXPR too soon.  And handle COMPOUND_EXPR inside
TARGET_EXPR better.

PR c++/104300
PR c++/92385

gcc/cp/ChangeLog:

* cp-tree.h (get_vec_init_expr): New.
(target_expr_needs_replace): New.
* cp-gimplify.cc (cp_gimplify_init_expr): Use it.
(struct cp_fold_data): New.
(cp_fold_r): Only genericize inits at end of fn.
(cp_fold_function): Here.
(cp_fully_fold_init): Not here.
* init.cc (build_vec_init): Use get_vec_init_expr.
* tree.cc (build_vec_init_expr): Likewise.
* typeck2.cc (split_nonconstant_init_1): Likewise.
(process_init_constructor): Wrap VEC_INIT_EXPR in
TARGET_EXPR.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/initlist-array14.C: New test.
gcc/cp/cp-gimplify.cc
gcc/cp/cp-tree.h
gcc/cp/init.cc
gcc/cp/tree.cc
gcc/cp/typeck2.cc
gcc/testsuite/g++.dg/cpp0x/initlist-array14.C [new file with mode: 0644]