aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2021-02-03 10:34:18 +0100
committerTobias Burnus <tobias@codesourcery.com>2021-02-03 10:34:18 +0100
commite3f9f80bfa9e58a90dfe75631921c78660342daf (patch)
treeee620165059b1f46968460ba8a94be68c872dd15 /gcc/fortran
parent1b06fcb0c9ec1110f4d6eb1dacf9c41222346f04 (diff)
downloadgcc-e3f9f80bfa9e58a90dfe75631921c78660342daf.zip
gcc-e3f9f80bfa9e58a90dfe75631921c78660342daf.tar.gz
gcc-e3f9f80bfa9e58a90dfe75631921c78660342daf.tar.bz2
Fortran: Fix Array dependency with local coarrays [PR98913]
gcc/fortran/ChangeLog: PR fortran/98913 * dependency.c (gfc_dep_resolver): Treat local access to coarrays like any array access in dependency analysis. gcc/testsuite/ChangeLog: PR fortran/98913 * gfortran.dg/coarray/array_temporary.f90: New test.
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/dependency.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/gcc/fortran/dependency.c b/gcc/fortran/dependency.c
index c9baca8..5de3b2c 100644
--- a/gcc/fortran/dependency.c
+++ b/gcc/fortran/dependency.c
@@ -30,6 +30,7 @@ along with GCC; see the file COPYING3. If not see
#include "dependency.h"
#include "constructor.h"
#include "arith.h"
+#include "options.h"
/* static declarations */
/* Enums */
@@ -2142,9 +2143,17 @@ gfc_dep_resolver (gfc_ref *lref, gfc_ref *rref, gfc_reverse *reverse,
return (fin_dep == GFC_DEP_OVERLAP) ? 1 : 0;
case REF_ARRAY:
-
- /* For now, treat all coarrays as dangerous. */
- if (lref->u.ar.codimen || rref->u.ar.codimen)
+ /* Coarrays: If there is a coindex, either the image differs and there
+ is no overlap or the image is the same - then the normal analysis
+ applies. Hence, return early only if 'identical' is required and
+ either ref is coindexed and more than one image can exist. */
+ if (identical && flag_coarray != GFC_FCOARRAY_SINGLE
+ && ((lref->u.ar.codimen
+ && lref->u.ar.dimen_type[lref->u.ar.dimen]
+ != DIMEN_THIS_IMAGE)
+ || (rref->u.ar.codimen
+ && lref->u.ar.dimen_type[lref->u.ar.dimen]
+ != DIMEN_THIS_IMAGE)))
return 1;
if (ref_same_as_full_array (lref, rref))