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

--- Comment #22 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathaniel Shead <[email protected]>:

https://gcc.gnu.org/g:858f300727833740f74d90378a0f302d4254ef37

commit r16-5727-g858f300727833740f74d90378a0f302d4254ef37
Author: Nathaniel Shead <[email protected]>
Date:   Sat Nov 15 15:27:13 2025 +1100

    c++: Support template block-scope OpenMP user-defined reductions in modules
[PR119864]

    There were two issues preventing OpenMP reductions of UDTs from working
    in modules.

    Firstly, we were failing a number of checking asserts in the streaming
    logic because the declaration is a DECL_LOCAL_DECL_P but was not
    correctly added to the BLOCK of the function template.  This is because
    cp_parser_omp_declare_reduction only called pushdecl when
    !processing_template_decl; correcting this fixed this issue.

    The second issue is that modules saw this as a function definition and
    so attempted to call allocate_struct_function on it, which crashes.
    Given that these reduction functions don't really behave like real
    function definitions in any other way, I think the cleanest solution is
    to just skip all the function definition post-processing in modules;
    this seems to work to get the test functioning correctly, from what I
    can see.

            PR c++/119864

    gcc/cp/ChangeLog:

            * module.cc (trees_in::read_function_def): Don't call
            post_process on OpenMP UDT reductions.
            * parser.cc (cp_parser_omp_declare_reduction): Call push_decl
            for block_scope, even when processing_template_decl.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/omp-4_a.C: New test.
            * g++.dg/modules/omp-4_b.C: New test.

    Signed-off-by: Nathaniel Shead <[email protected]>
    Reviewed-by: Jakub Jelinek <[email protected]>
    Reviewed-by: Jason Merrill <[email protected]>

Reply via email to