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

--- Comment #12 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

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

commit r15-7230-gad8e6a4ada0a7ed73ac99404ff2b41ed9dc5e940
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Mon Jan 27 16:45:56 2025 +0100

    c++: Implement for namespace statics CWG 2867 - Order of initialization for
structured bindings [PR115769]

    The following patch adds CWG 2867 support for namespace locals.

    Those vars are just pushed into {static,tls}_aggregates chain, then
    pruned from those lists, separated by priority and finally emitted into
    the corresponding dynamic initialization functions.
    The patch adds two flags used on the TREE_LIST nodes in those lists,
    one marks the structured binding base variable and/or associated ref
    extended temps, another marks the vars initialized using get methods.
    The flags are preserved across the pruning, for splitting into by priority
    all associated decls of a structured binding using tuple* are forced
    into the same priority as the first one, and finally when actually emitting
    code, CLEANUP_POINT_EXPRs are disabled in the base initializer(s) and
    code from the bases and non-bases together is wrapped into a single
    CLEANUP_POINT_EXPR.

    2025-01-27  Jakub Jelinek  <ja...@redhat.com>

            PR c++/115769
    gcc/cp/
            * cp-tree.h (STATIC_INIT_DECOMP_BASE_P): Define.
            (STATIC_INIT_DECOMP_NONBASE_P): Define.
            * decl.cc (cp_finish_decl): Mark nodes in {static,tls}_aggregates
            emitted for namespace scope structured bindings with
            STATIC_INIT_DECOMP_{,NON}BASE_P flags when needed.
            * decl2.cc (decomp_handle_one_var, decomp_finalize_var_list): New
            functions.
            (emit_partial_init_fini_fn): Use them.
            (prune_vars_needing_no_initialization): Assert
            STATIC_INIT_DECOMP_*BASE_P is not set on DECL_EXTERNAL vars to be
            pruned out.
            (partition_vars_for_init_fini): Use same priority for
            consecutive STATIC_INIT_DECOMP_*BASE_P vars and propagate
            those flags to new TREE_LISTs when possible.  Formatting fix.
            (handle_tls_init): Use decomp_handle_one_var and
            decomp_finalize_var_list functions.
    gcc/testsuite/
            * g++.dg/DRs/dr2867-5.C: New test.
            * g++.dg/DRs/dr2867-6.C: New test.
            * g++.dg/DRs/dr2867-7.C: New test.
            * g++.dg/DRs/dr2867-8.C: New test.

Reply via email to