From fcd443200bdf5cefcfd2a711ae6fae6239443aca Mon Sep 17 00:00:00 2001 From: Roger Sayle Date: Sun, 17 Dec 2006 18:28:07 +0000 Subject: re PR fortran/30207 (ICE in gfc_dep_resolver with where (a < 0) a(:) = 1) 2006-12-17 Roger Sayle Steven G. Kargl PR fortran/30207 * dependency.c (gfc_full_array_ref_p): New function to test whether the given array ref specifies the entire array. (gfc_dep_resolver): Use gfc_full_array_ref_p to analyze AR_FULL array refs against AR_SECTION array refs, and vice versa. * dependency.h (gfc_full_array_ref_p): Prototype here. * trans-array.c (gfc_conv_expr_descriptor): Use gfc_full_array_ref_p. * gfortran.fortran-torture/execute/where21.f90: New test. From-SVN: r119990 --- gcc/fortran/dependency.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'gcc/fortran/dependency.c') diff --git a/gcc/fortran/dependency.c b/gcc/fortran/dependency.c index 28c6498..f9ba445 100644 --- a/gcc/fortran/dependency.c +++ b/gcc/fortran/dependency.c @@ -1108,6 +1108,46 @@ 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. */ + +bool +gfc_full_array_ref_p (gfc_ref *ref) +{ + int i; + + if (ref->type != REF_ARRAY) + return false; + if (ref->u.ar.type == AR_FULL) + return true; + if (ref->u.ar.type != AR_SECTION) + return false; + + for (i = 0; i < ref->u.ar.dimen; i++) + { + /* Check the lower bound. */ + if (ref->u.ar.start[i] + && (!ref->u.ar.as + || !ref->u.ar.as->lower[i] + || gfc_dep_compare_expr (ref->u.ar.start[i], + ref->u.ar.as->lower[i]))) + return 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; + /* Check the stride. */ + if (ref->u.ar.stride[i] + && !gfc_expr_is_one (ref->u.ar.stride[i], 0)) + return false; + } + return true; +} + + /* Finds if two array references are overlapping or not. Return value 1 : array references are overlapping. @@ -1145,6 +1185,19 @@ gfc_dep_resolver (gfc_ref * lref, gfc_ref * rref) return 0; case REF_ARRAY: + 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; + else if (rref->u.ar.type == AR_FULL) + fin_dep = gfc_full_array_ref_p (lref) ? GFC_DEP_EQUAL + : GFC_DEP_OVERLAP; + else + return 1; + break; + } + for (n=0; n < lref->u.ar.dimen; n++) { /* Assume dependency when either of array reference is vector -- cgit v1.1