https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116416

--- Comment #13 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>:

https://gcc.gnu.org/g:e7bccec33beece4a46bc1b20ed375e803e97aa88

commit r15-9400-ge7bccec33beece4a46bc1b20ed375e803e97aa88
Author: Patrick Palka <ppa...@redhat.com>
Date:   Sat Apr 12 14:06:56 2025 -0400

    c++: improve constexpr prvalue folding [PR116416]

    This patch improves upon r15-6052-g12de1942a0a673 by performing prvalue
    folding with mce_false rather than mce_unknown when it's safe to do so
    (i.e. ff_mce_false is set), so that we can also fold temporary initializers
    that call is_constant_evaluated etc.

    In passing I noticed constexpr-prvalue1.C could more precisely verify the
    optimization happened by inspecting what the front end spits out instead
    of inspecting the optimized assembly -- that there's no constructor call
    doesn't necessarily imply the constructor has been completely folded away,
    only that its body has been inlined.

            PR c++/116416

    gcc/cp/ChangeLog:

            * constexpr.cc (maybe_constant_init_1): Generalize type of
            of manifestly_const_eval parameter from bool to mce_value.
            (maybe_constant_init): Define 3-parameter version taking a
            manifestly_const_eval instead of bool parameter.
            (cxx_constant_init): Adjust.
            * cp-gimplify.cc (cp_fold_r) <case TARGET_EXPR>: Pass mce_false
            to maybe_constant_init during prvalue folding if ff_mce_false is
            set.
            * cp-tree.h (maybe_constant_init): Declare new overload.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1y/constexpr-prvalue1.C: Adjust to instead inspect
            the 'original' dump.
            * g++.dg/cpp1y/constexpr-prvalue1a.C: New test.

    Reviewed-by: Jason Merrill <ja...@redhat.com>

Reply via email to