aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorJulian Brown <julian@codesourcery.com>2020-01-03 17:39:56 -0800
committerJulian Brown <julian@codesourcery.com>2020-01-28 06:00:30 -0800
commita5ed4958a2c1b563e933b25ca3b481761cc40b07 (patch)
tree1fa8f2157f7b0382370e65956bf4f2d569afcada /gcc/fortran
parent278c3214b344ac7c5daf974196fbebc531bff058 (diff)
downloadgcc-a5ed4958a2c1b563e933b25ca3b481761cc40b07.zip
gcc-a5ed4958a2c1b563e933b25ca3b481761cc40b07.tar.gz
gcc-a5ed4958a2c1b563e933b25ca3b481761cc40b07.tar.bz2
Check array contiguity for OpenACC/Fortran
PR fortran/93025 gcc/fortran/ * openmp.c (resolve_omp_clauses): Check array references for contiguity. gcc/testsuite/ * gfortran.dg/goacc/mapping-tests-2.f90: New test. * gfortran.dg/goacc/subarrays.f95: Expect rejection of non-contiguous array.
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog5
-rw-r--r--gcc/fortran/openmp.c29
2 files changed, 27 insertions, 7 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index c51dab2..c7e2b31 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,5 +1,10 @@
2020-01-28 Julian Brown <julian@codesourcery.com>
+ PR fortran/93025
+ * openmp.c (resolve_omp_clauses): Check array references for contiguity.
+
+2020-01-28 Julian Brown <julian@codesourcery.com>
+
* gfortran.h (gfc_symbol): Add comp_mark bitfield.
* openmp.c (resolve_omp_clauses): Disallow mixed component and
full-derived-type accesses to the same variable within a single
diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c
index 444fdcc..0accb18 100644
--- a/gcc/fortran/openmp.c
+++ b/gcc/fortran/openmp.c
@@ -4536,13 +4536,28 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
/* Look through component refs to find last array
reference. */
if (openacc && resolved)
- while (array_ref
- && (array_ref->type == REF_COMPONENT
- || (array_ref->type == REF_ARRAY
- && array_ref->next
- && (array_ref->next->type
- == REF_COMPONENT))))
- array_ref = array_ref->next;
+ {
+ /* The "!$acc cache" directive allows rectangular
+ subarrays to be specified, with some restrictions
+ on the form of bounds (not implemented).
+ Only raise an error here if we're really sure the
+ array isn't contiguous. An expression such as
+ arr(-n:n,-n:n) could be contiguous even if it looks
+ like it may not be. */
+ if (list != OMP_LIST_CACHE
+ && !gfc_is_simply_contiguous (n->expr, false, true)
+ && gfc_is_not_contiguous (n->expr))
+ gfc_error ("Array is not contiguous at %L",
+ &n->where);
+
+ while (array_ref
+ && (array_ref->type == REF_COMPONENT
+ || (array_ref->type == REF_ARRAY
+ && array_ref->next
+ && (array_ref->next->type
+ == REF_COMPONENT))))
+ array_ref = array_ref->next;
+ }
}
if (array_ref
|| (n->expr