c++: more mce_false folding from cp_fully_fold_init [PR108243]
commit5425159d176a7a92afc932cbb22d8822667099c4
authorPatrick Palka <ppalka@redhat.com>
Thu, 2 Mar 2023 19:04:50 +0000 (2 14:04 -0500)
committerPatrick Palka <ppalka@redhat.com>
Thu, 2 Mar 2023 19:04:50 +0000 (2 14:04 -0500)
tree349fd3034e3c174622bc76c8c359ba2f747a0876
parentcbaa1d9c218d9c0b5e34e510a462ff4e299a0f3f
c++: more mce_false folding from cp_fully_fold_init [PR108243]

We should also fold the overall initializer passed to cp_fully_fold_init
with mce_false, which allows folding of the copy-initialization of
'a1' in the below testcase (the initializer here is an AGGR_INIT_EXPR).

Unfortunately this doesn't help with direct- or default-initialization
because we don't call cp_fully_fold_init in that case, and even if we
did the initializer in that case is expressed as a bare CALL_EXPR
instead of an AGGR_INIT_EXPR, which cp_fully_fold_init can't really
fold.

PR c++/108243
PR c++/97553

gcc/cp/ChangeLog:

* cp-gimplify.cc (cp_fully_fold): Add an internal overload that
additionally takes and propagate an mce_value parameter, and
define the existing public overload in terms of it.
(cp_fully_fold_init): Pass mce_false to cp_fully_fold.

gcc/testsuite/ChangeLog:

* g++.dg/opt/is_constant_evaluated3.C: New test.
gcc/cp/cp-gimplify.cc
gcc/testsuite/g++.dg/opt/is_constant_evaluated3.C [new file with mode: 0644]