]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/59488 ([OpenMP] named constant in parallel construct leads to "not...
authorJakub Jelinek <jakub@redhat.com>
Fri, 10 Oct 2014 11:24:31 +0000 (13:24 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 10 Oct 2014 11:24:31 +0000 (13:24 +0200)
PR fortran/59488
* trans-openmp.c (gfc_omp_predetermined_sharing): Return
OMP_CLAUSE_DEFAULT_SHARED for parameters or vtables.

* gfortran.dg/gomp/pr59488-1.f90: New test.
* gfortran.dg/gomp/pr59488-2.f90: New test.

From-SVN: r216071

gcc/fortran/ChangeLog
gcc/fortran/trans-openmp.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/gomp/pr59488-1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/pr59488-2.f90 [new file with mode: 0644]

index c7001ca627c848280305f2be07f747c907391eae..b5dfcf1fa4708b27d0dad5003527f915cef27e1b 100644 (file)
@@ -1,3 +1,9 @@
+2014-10-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/59488
+       * trans-openmp.c (gfc_omp_predetermined_sharing): Return
+       OMP_CLAUSE_DEFAULT_SHARED for parameters or vtables.
+
 2014-09-03  Marek Polacek  <polacek@redhat.com>
 
        Backport from trunk
index 988dea92f58ace1a834b74bce83ca8f5e6abba87..53a78f08875f6bb334668611e73d5c8904a332d9 100644 (file)
@@ -115,6 +115,16 @@ gfc_omp_predetermined_sharing (tree decl)
   if (GFC_DECL_RESULT (decl) && ! DECL_HAS_VALUE_EXPR_P (decl))
     return OMP_CLAUSE_DEFAULT_SHARED;
 
+  /* These are either array or derived parameters, or vtables.
+     In the former cases, the OpenMP standard doesn't consider them to be
+     variables at all (they can't be redefined), but they can nevertheless appear
+     in parallel/task regions and for default(none) purposes treat them as shared.
+     For vtables likely the same handling is desirable.  */
+  if (TREE_CODE (decl) == VAR_DECL
+      && TREE_READONLY (decl)
+      && TREE_STATIC (decl))
+    return OMP_CLAUSE_DEFAULT_SHARED;
+
   return OMP_CLAUSE_DEFAULT_UNSPECIFIED;
 }
 
index ac676afcfcca5ef53ae8f729ab84a51652077dbf..65509575ed2454ead69c70c25bfdc27193dea60e 100644 (file)
@@ -1,3 +1,9 @@
+2014-10-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/59488
+       * gfortran.dg/gomp/pr59488-1.f90: New test.
+       * gfortran.dg/gomp/pr59488-2.f90: New test.
+
 2014-10-01  Jakub Jelinek  <jakub@redhat.com>
 
        PR debug/63342
diff --git a/gcc/testsuite/gfortran.dg/gomp/pr59488-1.f90 b/gcc/testsuite/gfortran.dg/gomp/pr59488-1.f90
new file mode 100644 (file)
index 0000000..9db17dd
--- /dev/null
@@ -0,0 +1,13 @@
+! PR fortran/59488
+! { dg-do compile }
+! { dg-options "-fopenmp" }
+
+  implicit none
+  integer, parameter :: p(2) = (/ 11, 12 /)
+  integer :: r
+
+  !$omp parallel do default(none)
+  do r = 1, 2
+    print *, p(r)
+  end do
+end
diff --git a/gcc/testsuite/gfortran.dg/gomp/pr59488-2.f90 b/gcc/testsuite/gfortran.dg/gomp/pr59488-2.f90
new file mode 100644 (file)
index 0000000..38f157b
--- /dev/null
@@ -0,0 +1,16 @@
+! PR fortran/59488
+! { dg-do compile }
+! { dg-options "-fopenmp" }
+
+  implicit none
+  type t
+    integer :: s1, s2, s3
+  end type
+  integer :: r
+  type(t), parameter :: u = t(1, 2, 3)
+
+  !$omp parallel do default(none)
+  do r = 1, 2
+    print *, u
+  end do
+end