summaryrefslogtreecommitdiff
path: root/gcc/fortran/dependency.c
diff options
context:
space:
mode:
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-29 20:38:59 +0000
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-29 20:38:59 +0000
commit8d60cc468e8c1956cef570588d4297ce3a740328 (patch)
treeaca49e7453dd7b8e481ea5b320d8145f0bddc97c /gcc/fortran/dependency.c
parente0ca1cb51d9b2ab809ab53276a9922bc90b892b1 (diff)
downloadgcc-8d60cc468e8c1956cef570588d4297ce3a740328.tar.gz
2009-06-29 Paul Thomas <pault@gcc.gnu.org>
PR fortran/40551 * dependency.h : Add second bool* argument to prototype of gfc_full_array_ref_p. * dependency.c (gfc_full_array_ref_p): If second argument is present, return true if last dimension of reference is an element or has unity stride. * trans-array.c : Add NULL second argument to references to gfc_full_array_ref_p. * trans-expr.c : The same, except for; (gfc_trans_arrayfunc_assign): Return fail if lhs reference is not a full array or a contiguous section. 2009-06-29 Paul Thomas <pault@gcc.gnu.org> PR fortran/40551 * gfortran.dg/func_assign_2.f90 : New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149062 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/dependency.c')
-rw-r--r--gcc/fortran/dependency.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/gcc/fortran/dependency.c b/gcc/fortran/dependency.c
index 5f74c34ac5c..eb07e7c5db6 100644
--- a/gcc/fortran/dependency.c
+++ b/gcc/fortran/dependency.c
@@ -1186,12 +1186,16 @@ gfc_check_element_vs_element (gfc_ref *lref, gfc_ref *rref, int n)
/* Determine if an array ref, usually an array section specifies the
- entire array. */
+ entire array. In addition, if the second, pointer argument is
+ provided, the function will return true if the reference is
+ contiguous; eg. (:, 1) gives true but (1,:) gives false. */
bool
-gfc_full_array_ref_p (gfc_ref *ref)
+gfc_full_array_ref_p (gfc_ref *ref, bool *contiguous)
{
int i;
+ bool lbound_OK = true;
+ bool ubound_OK = true;
if (ref->type != REF_ARRAY)
return false;
@@ -1209,6 +1213,10 @@ gfc_full_array_ref_p (gfc_ref *ref)
the correct element. */
if (ref->u.ar.dimen_type[i] == DIMEN_ELEMENT)
{
+ /* This is a contiguous reference. */
+ if (contiguous)
+ *contiguous = (i + 1 == ref->u.ar.dimen);
+
if (!ref->u.ar.as
|| !ref->u.ar.as->lower[i]
|| !ref->u.ar.as->upper[i]
@@ -1228,17 +1236,24 @@ gfc_full_array_ref_p (gfc_ref *ref)
|| !ref->u.ar.as->lower[i]
|| gfc_dep_compare_expr (ref->u.ar.start[i],
ref->u.ar.as->lower[i])))
- return false;
+ lbound_OK = false;
/* Check the upper bound. */
if (ref->u.ar.end[i]
&& (!ref->u.ar.as
|| !ref->u.ar.as->upper[i]
|| gfc_dep_compare_expr (ref->u.ar.end[i],
ref->u.ar.as->upper[i])))
- return false;
+ ubound_OK = false;
/* Check the stride. */
if (ref->u.ar.stride[i] && !gfc_expr_is_one (ref->u.ar.stride[i], 0))
return false;
+
+ /* This is a contiguous reference. */
+ if (contiguous)
+ *contiguous = (i + 1 == ref->u.ar.dimen);
+
+ if (!lbound_OK || !ubound_OK)
+ return false;
}
return true;
}
@@ -1356,11 +1371,11 @@ gfc_dep_resolver (gfc_ref *lref, gfc_ref *rref)
if (lref->u.ar.dimen != rref->u.ar.dimen)
{
if (lref->u.ar.type == AR_FULL)
- fin_dep = gfc_full_array_ref_p (rref) ? GFC_DEP_EQUAL
- : GFC_DEP_OVERLAP;
+ fin_dep = gfc_full_array_ref_p (rref, NULL) ? GFC_DEP_EQUAL
+ : GFC_DEP_OVERLAP;
else if (rref->u.ar.type == AR_FULL)
- fin_dep = gfc_full_array_ref_p (lref) ? GFC_DEP_EQUAL
- : GFC_DEP_OVERLAP;
+ fin_dep = gfc_full_array_ref_p (lref, NULL) ? GFC_DEP_EQUAL
+ : GFC_DEP_OVERLAP;
else
return 1;
break;