re PR fortran/78866 (ICE in gimplify_adjust_omp_clauses_1, at gimplify.c:8721)
authorJakub Jelinek <jakub@redhat.com>
Wed, 21 Dec 2016 16:16:20 +0000 (17:16 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 21 Dec 2016 16:16:20 +0000 (17:16 +0100)
PR fortran/78866
* openmp.c (resolve_omp_clauses): Diagnose assumed size arrays in
OpenMP map, to and from clauses.
* trans-openmp.c: Include diagnostic-core.h, temporarily redefining
GCC_DIAG_STYLE to __gcc_tdiag__.
(gfc_omp_finish_clause): Diagnose implicitly mapped assumed size
arrays.

* gfortran.dg/gomp/map-1.f90: Add expected error.
* gfortran.dg/gomp/pr78866-1.f90: New test.
* gfortran.dg/gomp/pr78866-2.f90: New test.

From-SVN: r243860

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

index 6bec5e794db02113272b748e7f9e4ab385510e81..ea284f45e0243235108f37c7b894b1d9f39e18dc 100644 (file)
@@ -1,3 +1,13 @@
+2016-12-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/78866
+       * openmp.c (resolve_omp_clauses): Diagnose assumed size arrays in
+       OpenMP map, to and from clauses.
+       * trans-openmp.c: Include diagnostic-core.h, temporarily redefining
+       GCC_DIAG_STYLE to __gcc_tdiag__.
+       (gfc_omp_finish_clause): Diagnose implicitly mapped assumed size
+       arrays.
+
 2016-12-21  Janne Blomqvist  <jb@gcc.gnu.org>
 
        PR fortran/78867
index 11ffb5d884c582a1524e608e2a294d038ea13d56..da4499190d1592ff4500599475343bd4a8140049 100644 (file)
@@ -4382,6 +4382,11 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
                    else
                      resolve_oacc_data_clauses (n->sym, n->where, name);
                  }
+               else if (list != OMP_CLAUSE_DEPEND
+                        && n->sym->as
+                        && n->sym->as->type == AS_ASSUMED_SIZE)
+                 gfc_error ("Assumed size array %qs in %s clause at %L",
+                            n->sym->name, name, &n->where);
                if (list == OMP_LIST_MAP && !openacc)
                  switch (code->op)
                    {
index 53f92b049ab86c838fa1f9e98662fc51885b1d27..3e22ebf8ced11f088f4c36c7a969e3f7539d91cd 100644 (file)
@@ -38,6 +38,11 @@ along with GCC; see the file COPYING3.  If not see
 #include "gomp-constants.h"
 #include "omp-general.h"
 #include "omp-low.h"
+#undef GCC_DIAG_STYLE
+#define GCC_DIAG_STYLE __gcc_tdiag__
+#include "diagnostic-core.h"
+#undef GCC_DIAG_STYLE
+#define GCC_DIAG_STYLE __gcc_gfc__
 
 int ompws_flags;
 
@@ -1039,6 +1044,21 @@ gfc_omp_finish_clause (tree c, gimple_seq *pre_p)
     return;
 
   tree decl = OMP_CLAUSE_DECL (c);
+
+  /* Assumed-size arrays can't be mapped implicitly, they have to be
+     mapped explicitly using array sections.  */
+  if (TREE_CODE (decl) == PARM_DECL
+      && GFC_ARRAY_TYPE_P (TREE_TYPE (decl))
+      && GFC_TYPE_ARRAY_AKIND (TREE_TYPE (decl)) == GFC_ARRAY_UNKNOWN
+      && GFC_TYPE_ARRAY_UBOUND (TREE_TYPE (decl),
+                               GFC_TYPE_ARRAY_RANK (TREE_TYPE (decl)) - 1)
+        == NULL)
+    {
+      error_at (OMP_CLAUSE_LOCATION (c),
+               "implicit mapping of assumed size array %qD", decl);
+      return;
+    }
+
   tree c2 = NULL_TREE, c3 = NULL_TREE, c4 = NULL_TREE;
   if (POINTER_TYPE_P (TREE_TYPE (decl)))
     {
index 5c47a0dcce0d70e4abfe682a6e812563257da42c..f3e48bb3bb6b580d9fb63e20d78f68cc35556b01 100644 (file)
@@ -1,3 +1,10 @@
+2016-12-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/78866
+       * gfortran.dg/gomp/map-1.f90: Add expected error.
+       * gfortran.dg/gomp/pr78866-1.f90: New test.
+       * gfortran.dg/gomp/pr78866-2.f90: New test.
+
 2016-12-21  David Edelsohn  <dje.gcc@gmail.com>
 
        * gcc.dg/vect/costmodel/ppc/costmodel-bb-slp-9a-pr63175.c: XFAIL
index e4b8b862afdcff9fb9e559f88b855aa8ad50646e..e78b56c8f392fef6ffc9be50cb56aa92a241b097 100644 (file)
@@ -70,7 +70,7 @@ subroutine test(aas)
   ! { dg-error "Rightmost upper bound of assumed size array section not specified" "" { target *-*-* } 68 }
   ! { dg-error "'aas' in MAP clause at \\\(1\\\) is not a proper array section" "" { target *-*-* } 68 }
 
-  !$omp target map(aas) ! { dg-error "The upper bound in the last dimension must appear" "" { xfail *-*-* } }
+  !$omp target map(aas) ! { dg-error "Assumed size array" }
   !$omp end target
 
   !$omp target map(aas(5:7))
diff --git a/gcc/testsuite/gfortran.dg/gomp/pr78866-1.f90 b/gcc/testsuite/gfortran.dg/gomp/pr78866-1.f90
new file mode 100644 (file)
index 0000000..63a0be7
--- /dev/null
@@ -0,0 +1,19 @@
+! PR fortran/78866
+! { dg-do compile }
+
+subroutine pr78866(x)
+  integer :: x(*)
+!$omp target map(x)                    ! { dg-error "Assumed size array" }
+  x(1) = 1
+!$omp end target
+!$omp target data map(tofrom: x)       ! { dg-error "Assumed size array" }
+!$omp target update to(x)              ! { dg-error "Assumed size array" }
+!$omp target update from(x)            ! { dg-error "Assumed size array" }
+!$omp end target data
+!$omp target map(x(:23))               ! { dg-bogus "Assumed size array" }
+  x(1) = 1
+!$omp end target
+!$omp target map(x(:))                 ! { dg-error "upper bound of assumed size array section" }
+  x(1) = 1                             ! { dg-error "not a proper array section" "" { target *-*-* } .-1 }
+!$omp end target
+end
diff --git a/gcc/testsuite/gfortran.dg/gomp/pr78866-2.f90 b/gcc/testsuite/gfortran.dg/gomp/pr78866-2.f90
new file mode 100644 (file)
index 0000000..033479e
--- /dev/null
@@ -0,0 +1,9 @@
+! PR fortran/78866
+! { dg-do compile }
+
+subroutine pr78866(x)
+  integer :: x(*)
+!$omp target           ! { dg-error "implicit mapping of assumed size array" }
+  x(1) = 1
+!$omp end target
+end