re PR fortran/59488 ([OpenMP] named constant in parallel construct leads to "not...
authorJakub Jelinek <jakub@redhat.com>
Fri, 10 Oct 2014 11:08:37 +0000 (13:08 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 10 Oct 2014 11:08:37 +0000 (13:08 +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: r216067

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 907e32a7cbcecf8e2b4e559b1db3eb3b075df5f1..88fc33f87b440ba0febcd85e1a8d1015485a927f 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-10-10  Tobias Burnus  <burnus@net-b.de>
 
        * gfortran.h (gfc_set_implicit_none): Update prototype.
index c8028ab269a535b12e92e036da03c37096959b8d..038c3e9a6e4095faba6da93874f6a39fd11dffc7 100644 (file)
@@ -135,6 +135,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 2ed4d4a06124f53144440eef50867e9715730490..d9e93d352a9e4439ad82aacd3e7caa595c5d13cd 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-10  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/63476
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