]> gcc.gnu.org Git - gcc.git/commit
openmp: Add support for OpenMP 5.1 atomics for C++
authorJakub Jelinek <jakub@redhat.com>
Fri, 17 Sep 2021 13:20:20 +0000 (15:20 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Fri, 17 Sep 2021 13:20:20 +0000 (15:20 +0200)
commitb6ae294ac21f79a3f1736ab86ebdf7a43527a0f0
treeff444bc23faaea88dce12c06fdb8930d2e157e5b
parentea29d3d097a730ea714ae2992044a80609d030df
openmp: Add support for OpenMP 5.1 atomics for C++

Besides the C++ FE changes, I've noticed that the C FE didn't reject
  #pragma omp atomic capture compare
  { v = x; x = y; }
and other forms of atomic swap, this patch fixes that too.  And the
c-family/ routine needed quite a few changes so that the new code
in it works fine with both FEs.

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

gcc/c-family/
* c-omp.c (c_finish_omp_atomic): Avoid creating
TARGET_EXPR if test is true, use create_tmp_var_raw instead of
create_tmp_var and add a zero initializer to TARGET_EXPRs that
had NULL initializer.  When omitting operands after v = x,
use type of v rather than type of x.  Fix type of vtmp
TARGET_EXPR.
gcc/c/
* c-parser.c (c_parser_omp_atomic): Reject atomic swap if capture
is true.
gcc/cp/
* cp-tree.h (finish_omp_atomic): Add r and weak arguments.
* parser.c (cp_parser_omp_atomic): Update function comment for
OpenMP 5.1 atomics, parse OpenMP 5.1 atomics and fail, compare and
weak clauses.
* semantics.c (finish_omp_atomic): Add r and weak arguments, handle
them, handle COND_EXPRs.
* pt.c (tsubst_expr): Adjust for COND_EXPR forms that
finish_omp_atomic can now produce.
gcc/testsuite/
* c-c++-common/gomp/atomic-18.c: Expect same diagnostics in C++ as in
C.
* c-c++-common/gomp/atomic-25.c: Drop c effective target.
* c-c++-common/gomp/atomic-26.c: Likewise.
* c-c++-common/gomp/atomic-27.c: Likewise.
* c-c++-common/gomp/atomic-28.c: Likewise.
* c-c++-common/gomp/atomic-29.c: Likewise.
* c-c++-common/gomp/atomic-30.c: Likewise.  Adjust expected diagnostics
for C++ when it differs from C.
(foo): Change return type from double to void.
* g++.dg/gomp/atomic-5.C: Adjust expected diagnostics wording.
* g++.dg/gomp/atomic-20.C: New test.
libgomp/
* testsuite/libgomp.c-c++-common/atomic-19.c: Drop c effective target.
Use /* */ comments instead of //.
* testsuite/libgomp.c-c++-common/atomic-20.c: Likewise.
* testsuite/libgomp.c-c++-common/atomic-21.c: Likewise.
* testsuite/libgomp.c++/atomic-16.C: New test.
* testsuite/libgomp.c++/atomic-17.C: New test.

(cherry picked from commit 3a2bcffac602f5de56537a77db1062984bcefd45)
25 files changed:
gcc/c-family/ChangeLog.omp
gcc/c-family/c-omp.c
gcc/c/ChangeLog.omp
gcc/c/c-parser.c
gcc/cp/ChangeLog.omp
gcc/cp/cp-tree.h
gcc/cp/parser.c
gcc/cp/pt.c
gcc/cp/semantics.c
gcc/testsuite/ChangeLog.omp
gcc/testsuite/c-c++-common/gomp/atomic-18.c
gcc/testsuite/c-c++-common/gomp/atomic-25.c
gcc/testsuite/c-c++-common/gomp/atomic-26.c
gcc/testsuite/c-c++-common/gomp/atomic-27.c
gcc/testsuite/c-c++-common/gomp/atomic-28.c
gcc/testsuite/c-c++-common/gomp/atomic-29.c
gcc/testsuite/c-c++-common/gomp/atomic-30.c
gcc/testsuite/g++.dg/gomp/atomic-20.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/atomic-5.C
libgomp/ChangeLog.omp
libgomp/testsuite/libgomp.c++/atomic-16.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/atomic-17.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c-c++-common/atomic-19.c
libgomp/testsuite/libgomp.c-c++-common/atomic-20.c
libgomp/testsuite/libgomp.c-c++-common/atomic-21.c
This page took 0.067611 seconds and 5 git commands to generate.