From 08fff201c92109b5476a4cc211c71de557ec87b1 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Tue, 4 May 2021 09:22:36 +0200 Subject: [PATCH] OpenMP/Fortran - fix pasto + testcase in depobj [PR100397] gcc/fortran/ChangeLog: PR testsuite/100397 * trans-openmp.c (gfc_trans_omp_depobj): Fix pasto in enum values. libgomp/ChangeLog: PR testsuite/100397 * testsuite/libgomp.fortran/depobj-1.f90 (dep2, dep3): Move var declaration to scope of non-'depend'-guarded assignment to avoid races. --- gcc/fortran/trans-openmp.c | 4 ++-- libgomp/testsuite/libgomp.fortran/depobj-1.f90 | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index bf3f261..aa3a82e 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -4964,8 +4964,8 @@ gfc_trans_omp_depobj (gfc_code *code) ? code->ext.omp_clauses->depobj_update : n->u.depend_op) { case OMP_DEPEND_IN: k = GOMP_DEPEND_IN; break; - case OMP_DEPEND_OUT: k = GOMP_DEPEND_IN; break; - case OMP_DEPEND_INOUT: k = GOMP_DEPEND_IN; break; + case OMP_DEPEND_OUT: k = GOMP_DEPEND_OUT; break; + case OMP_DEPEND_INOUT: k = GOMP_DEPEND_INOUT; break; case OMP_DEPEND_MUTEXINOUTSET: k = GOMP_DEPEND_MUTEXINOUTSET; break; default: gcc_unreachable (); } diff --git a/libgomp/testsuite/libgomp.fortran/depobj-1.f90 b/libgomp/testsuite/libgomp.fortran/depobj-1.f90 index 1e239bba..273b10c 100644 --- a/libgomp/testsuite/libgomp.fortran/depobj-1.f90 +++ b/libgomp/testsuite/libgomp.fortran/depobj-1.f90 @@ -28,20 +28,20 @@ contains end subroutine dep2 - integer, pointer :: x integer(omp_depend_kind) :: d1, d2 pointer :: d1 - allocate(d1, x) - call dep2i(d1, d2, x) + allocate(d1) + call dep2i(d1, d2) deallocate(d1) contains - subroutine dep2i(d1, d2, x) + subroutine dep2i(d1, d2) integer(omp_depend_kind) :: d1 integer(omp_depend_kind), optional :: d2 - integer, pointer, optional :: x pointer :: d1 !$omp parallel !$omp single + block + integer :: x x = 1 !$omp depobj (d1) depend(out: x) !$omp depobj (d2) depend (in:x) @@ -56,15 +56,17 @@ contains !$omp taskwait !$omp depobj(d1)destroy !$omp depobj(d2) destroy + end block !$omp end single !$omp end parallel end end subroutine dep3 - integer :: x integer(omp_depend_kind) :: d(2) !$omp parallel + block + integer :: x x = 1 !$omp single !$omp depobj(d(1)) depend(out:x) @@ -77,6 +79,7 @@ contains stop 3 !$omp end task !$omp end single + end block !$omp end parallel !$omp depobj(d(1)) destroy !$omp depobj(d(2)) destroy -- 2.7.4