]> git.ipfire.org Git - thirdparty/gcc.git/commit
openmp: Allow private or firstprivate arguments to default clause even for C/C++
authorJakub Jelinek <jakub@redhat.com>
Mon, 20 Sep 2021 06:49:26 +0000 (08:49 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Mon, 20 Sep 2021 06:49:26 +0000 (08:49 +0200)
commit4956a69d1286efee2c9db3526514069326404743
tree7f9baa879c23ced6512dc89a35df62afff3b430f
parent7dfdbb9e7dd9eeb2de055e72940f935d4c6fc556
openmp: Allow private or firstprivate arguments to default clause even for C/C++

OpenMP 5.1 allows default(private) or default(firstprivate) even in C/C++,
but it behaves the same way as in Fortran only for variables not declared at
namespace or file scope.  For the namespace/file scope variables it instead
behaves as default(none).

2021-09-18  Jakub Jelinek  <jakub@redhat.com>

gcc/
* gimplify.c (omp_default_clause): For C/C++ default({,first}private),
if file/namespace scope variable doesn't have predetermined sharing,
treat it as if there was default(none).
gcc/c/
* c-parser.c (c_parser_omp_clause_default): Handle private and
firstprivate arguments, adjust diagnostics on unknown argument.
gcc/cp/
* parser.c (cp_parser_omp_clause_default): Handle private and
firstprivate arguments, adjust diagnostics on unknown argument.
* cp-gimplify.c (cxx_omp_finish_clause): Handle OMP_CLAUSE_PRIVATE.
gcc/testsuite/
* c-c++-common/gomp/default-2.c: New test.
* c-c++-common/gomp/default-3.c: New test.
* g++.dg/gomp/default-1.C: New test.
libgomp/
* testsuite/libgomp.c++/default-1.C: New test.
* testsuite/libgomp.c-c++-common/default-1.c: New test.
* libgomp.texi (OpenMP 5.1): Mark "private and firstprivate argument
to default clause in C and C++" as implemented.

(cherry picked from commit e5597f2ad55219092929dc12ea15e1edba06df18)
15 files changed:
gcc/ChangeLog.omp
gcc/c/ChangeLog.omp
gcc/c/c-parser.c
gcc/cp/ChangeLog.omp
gcc/cp/cp-gimplify.c
gcc/cp/parser.c
gcc/gimplify.c
gcc/testsuite/ChangeLog.omp
gcc/testsuite/c-c++-common/gomp/default-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/gomp/default-3.c [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/default-1.C [new file with mode: 0644]
libgomp/ChangeLog.omp
libgomp/libgomp.texi
libgomp/testsuite/libgomp.c++/default-1.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c-c++-common/default-1.c [new file with mode: 0644]