c++: don't cleanup the last aggregate elt
authorJason Merrill <jason@redhat.com>
Tue, 4 Jan 2022 20:25:07 +0000 (15:25 -0500)
committerJason Merrill <jason@redhat.com>
Fri, 7 Jan 2022 00:23:17 +0000 (19:23 -0500)
commit40140b734487cbe03cd897dca47120317f898004
tree4741f377c87c1dc20ef077a7cc3c27da9610af21
parent4f6bc28fc7dd86bd9e7408cbf28de1e973dd1eda
c++: don't cleanup the last aggregate elt

Now that we're building cleanups for aggregate elements more often, it seems
worth optimizing by avoiding building one for the last element; once it is
initialized, the complete object is fully initialized, the element cleanups
end in favor of the complete object cleanup, and so a cleanup for the last
element would guard nothing at all.

gcc/cp/ChangeLog:

* typeck2.c (split_nonconstant_init_1): Don't cleanup the last elt.
(split_nonconstant_init): Adjust.

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/aggregate1.C: New test.
gcc/cp/typeck2.c
gcc/testsuite/g++.dg/tree-ssa/aggregate1.C [new file with mode: 0644]