]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++/modules: Fix assertion in write_function_def for DECL_LOCAL_DECL_P
authorNathaniel Shead <nathanieloshead@gmail.com>
Sun, 30 Nov 2025 03:43:33 +0000 (14:43 +1100)
committerNathaniel Shead <nathanieloshead@gmail.com>
Mon, 1 Dec 2025 23:12:06 +0000 (10:12 +1100)
I hadn't retested r16-5727-g858f3007278337 on trunk before pushing and
I'd missed that it interacts badly with the assertion added by
r16-5305-gc38bf35f0c7fa1.  This adjusts the assertion to not check OMP
user-defined reductions (as they won't have import_export_decl called on
them anyway).

PR c++/119864
PR c++/122939

gcc/cp/ChangeLog:

* module.cc (trees_out::write_function_def): Don't crash on
OMP used-defined type reduction function definitions.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
gcc/cp/module.cc

index ea22cef24a5b944efd008904c2a4f2cdfcc33e7a..7b3f9326a2a2bb9efa5e3500fb7cb1a3fb56e611 100644 (file)
@@ -12935,6 +12935,9 @@ trees_out::write_function_def (tree decl)
       /* Make sure DECL_REALLY_EXTERN and DECL_INTERFACE_KNOWN are consistent
         on non-templates or we'll crash later in import_export_decl.  */
       gcc_checking_assert (flags || DECL_INTERFACE_KNOWN (decl)
+                          || (DECL_LANG_SPECIFIC (decl)
+                              && DECL_LOCAL_DECL_P (decl)
+                              && DECL_OMP_DECLARE_REDUCTION_P (decl))
                           || (DECL_LANG_SPECIFIC (decl)
                               && DECL_TEMPLATE_INFO (decl)
                               && uses_template_parms (DECL_TI_ARGS (decl))));