]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR fortran/78866 (ICE in gimplify_adjust_omp_clauses_1, at gimplify...
authorJakub Jelinek <jakub@redhat.com>
Tue, 30 May 2017 07:52:55 +0000 (09:52 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 30 May 2017 07:52:55 +0000 (09:52 +0200)
Backported from mainline
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.

* 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: r248636

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 0a90013c167dc9c3eefc79e834954f0c6fa54fe9..5d2f3b4aa6e46fbc839f800e34d9dbe4bbd1060d 100644 (file)
@@ -1,6 +1,16 @@
 2017-05-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       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-09-27  Jakub Jelinek  <jakub@redhat.com>
 
        PR fortran/77666
index 21de6072cc2f55af6b89bb13c9f8a42444ef8977..42c465cc68e22f10ff6845a136cdb0e9c1724301 100644 (file)
@@ -3166,6 +3166,11 @@ resolve_omp_clauses (gfc_code *code, locus *where,
                    else
                      resolve_oacc_data_clauses (n->sym, *where, name);
                  }
+               else if (list != OMP_LIST_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, where);
              }
 
            if (list != OMP_LIST_DEPEND)
index 906781d9b8389bd6b72819f8c72b5bdb4a0c70ac..761712fde04f6439ae82c0401c63ba5b138bd3c6 100644 (file)
@@ -47,6 +47,11 @@ along with GCC; see the file COPYING3.  If not see
 #include "arith.h"
 #include "omp-low.h"
 #include "gomp-constants.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;
 
@@ -1038,6 +1043,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 ffd3164df19aab3c5a7cc0e9aad0dd30355ddc46..51e63c6bd2a374e0ab8036e41177393d48a4bcae 100644 (file)
@@ -3,6 +3,11 @@
        Backported from mainline
        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.
+
        PR c/77767
        * gcc.c-torture/execute/pr77767.c: New test.
 
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..e557d6d
--- /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 *-*-* } 16 }
+!$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