c++: constexpr empty subobject elision [PR110197]
commita426b91b27e28985f47d16827a532fbc28c09bd7
authorPatrick Palka <ppalka@redhat.com>
Thu, 27 Jul 2023 13:10:07 +0000 (27 09:10 -0400)
committerPatrick Palka <ppalka@redhat.com>
Thu, 27 Jul 2023 13:10:07 +0000 (27 09:10 -0400)
tree49241c41c1efce77480b4ae913e5acee20d0ed93
parent33b153ff521e2f33acf7d076f8625d85319b731d
c++: constexpr empty subobject elision [PR110197]

Now that init_subob_ctx no longer sets new_ctx.ctor for a subobject of
empty type, it seems we need to ensure its callers also consistently
omit entries in the parent ctx->ctor for such subobjects.  We also need
to allow cxx_eval_array_reference to synthesize an empty subobject even
if the array CONSTRUCTOR has CONSTRUCTOR_NO_CLEARING set.

PR c++/110197

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_array_reference): Allow synthesizing an
empty subobject even if CONSTRUCTOR_NO_CLEARING is set.
(cxx_eval_bare_aggregate): Set 'no_slot' to true more generally
whenever new_ctx.ctor is set to NULL_TREE by init_subob_ctx,
i.e. whenever initializing an subobject of empty type.
(cxx_eval_vec_init_1): Define 'no_slot' as above and use it
accordingly.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-empty18.C: New test.
* g++.dg/cpp0x/constexpr-empty19.C: New test.
gcc/cp/constexpr.cc
gcc/testsuite/g++.dg/cpp0x/constexpr-empty18.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/constexpr-empty19.C [new file with mode: 0644]