[committed] OpenMP/Fortran - fix pasto + testcase in depobj [PR100397]

Message ID 5f30b34e-3523-12e1-4d13-299cdddb0bc1@codesourcery.com
State New
Headers show
Series
  • [committed] OpenMP/Fortran - fix pasto + testcase in depobj [PR100397]
Related show

Commit Message

Tobias Burnus May 4, 2021, 7:28 a.m.
Missed a copy-and-paste edit – and I had to move the
declaration of the variables further inside to avoid
races - the 'x = 1' assignment has to be at the same
scope as the var declaration.

Interestingly, the runs were rather stable; here it
passed for tens to hundreds of runs before failing.

Committed as r12-399-g08fff201c92109b5476a4cc211c71de557ec87b1

Tobias

-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf

Patch

commit 08fff201c92109b5476a4cc211c71de557ec87b1
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Tue May 4 09:22:36 2021 +0200

    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 bf3f2617776..aa3a82e3489 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 1e239bba492..273b10c09c5 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