backport: re PR c++/60228 (ICE using lambda in #pragma omp declare reduction)
commit1aafdd7c93226cb092b560462028394a82f404a2
authorJakub Jelinek <jakub@redhat.com>
Fri, 14 Feb 2020 11:56:42 +0000 (14 12:56 +0100)
committerJakub Jelinek <jakub@redhat.com>
Fri, 14 Feb 2020 15:01:44 +0000 (14 16:01 +0100)
treec89935ecccdd134c73928d9a16a1dd63fcf5a742
parentbf5e3130c0ed518311a79c5a0099e0e39f33a889
backport: re PR c++/60228 (ICE using lambda in #pragma omp declare reduction)

Backported from mainline
2019-11-29  Jakub Jelinek  <jakub@redhat.com>

PR c++/60228
* parser.c (cp_parser_omp_declare_reduction_exprs): If
processing_template_decl, wrap the combiner or initializer
into EXPR_STMT.
* decl.c (start_preparsed_function): Don't start a lambda scope
for DECL_OMP_DECLARE_REDUCTION_P functions.
(finish_function): Don't finish a lambda scope for
DECL_OMP_DECLARE_REDUCTION_P functions, nor cp_fold_function
them nor cp_genericize them.
* mangle.c (decl_mangling_context): Look through
DECL_OMP_DECLARE_REDUCTION_P functions.
* semantics.c (expand_or_defer_fn_1): For DECL_OMP_DECLARE_REDUCTION_P
functions, use tentative linkage, don't keep their bodies with
-fkeep-inline-functions and return false at the end.

* g++.dg/gomp/openmp-simd-2.C: Don't expect bodies for
DECL_OMP_DECLARE_REDUCTION_P functions.

* testsuite/libgomp.c++/udr-20.C: New test.
* testsuite/libgomp.c++/udr-21.C: New test.
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/mangle.c
gcc/cp/parser.c
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gomp/openmp-simd-2.C
libgomp/ChangeLog
libgomp/testsuite/libgomp.c++/udr-20.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/udr-21.C [new file with mode: 0644]