c++: local-scope OMP UDR reductions have no template head
authorNathan Sidwell <nathan@acm.org>
Wed, 16 Sep 2020 18:04:19 +0000 (11:04 -0700)
committerNathan Sidwell <nathan@acm.org>
Wed, 16 Sep 2020 19:16:11 +0000 (12:16 -0700)
commit8155316c6fc23045e8e056e91449a6e9863c357f
treeeb49f081f6ba90d0eda09fd14b4861a1af0ac019
parentd1339b519ae8cc4ae550baa127a21d8350462837
c++: local-scope OMP UDR reductions have no template head

This corrects the earlier problems with removing the template header
from local omp reductions.  And it uncovered a latent bug.  When we
tsubst such a decl, we immediately tsubst its body.
cp_check_omp_declare_reduction gets a success return value to gate
that instantiation.

udr-2.C got a further error, as the omp checking machinery doesn't
appear to turn the reduction into an error mark when failing.  I
didn't dig into that further.  udr-3.C appears to have been invalid
and accidentally worked.

gcc/cp/
* cp-tree.h (cp_check_omp_declare_reduction): Return bool.
* semantics.c (cp_check_omp_declare_reduction): Return true on for
success.
* pt.c (push_template_decl_real): OMP reductions do not get a
template header.
(tsubst_function_decl): Remove special casing for local decl omp
reductions.
(tsubst_expr): Call instantiate_body for a local omp reduction.
(instantiate_body): Add nested_p parm, and deal with such
instantiations.
(instantiate_decl): Reject FUNCTION_SCOPE entities, adjust
instantiate_body call.
gcc/testsuite/
* g++.dg/gomp/udr-2.C: Add additional expected error.
libgomp/
* testsuite/libgomp.c++/udr-3.C: Add missing ctor.
gcc/cp/cp-tree.h
gcc/cp/pt.c
gcc/cp/semantics.c
gcc/testsuite/g++.dg/gomp/udr-2.C
libgomp/testsuite/libgomp.c++/udr-3.C