]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR fortran/57023 (Not packing arrays with changing variable used for...
authorThomas Koenig <tkoenig@netcologne.de>
Sat, 24 Jan 2015 15:20:56 +0000 (15:20 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sat, 24 Jan 2015 15:20:56 +0000 (15:20 +0000)
2015-01-24  Thomas Koenig  <tkoenig@netcologne.de>

Backport from trunk
PR fortran/57023
* dependency.c (callback_dummy_intent_not_int):  New function.
(dummy_intent_not_in):  New function.
(gfc_full_array_ref_p):  Use dummy_intent_not_in.

2015-01-24  Thomas Koenig  <tkoenig@netcologne.de>

Backport from trunk
PR fortran/57023
* gfortran.dg/internal_pack_15.f90:  New test.

From-SVN: r220082

gcc/fortran/ChangeLog
gcc/fortran/dependency.c
gcc/testsuite/ChangeLog

index 18f4b3f1d3a2141e378d2484928749a35cf4d41b..646a68db592d12d7e2906ccfe3de8e6a715a466b 100644 (file)
@@ -1,3 +1,11 @@
+2015-01-24  Thomas Koenig  <tkoenig@netcologne.de>
+
+       Backport from trunk
+       PR fortran/57023
+       * dependency.c (callback_dummy_intent_not_int):  New function.
+       (dummy_intent_not_in):  New function.
+       (gfc_full_array_ref_p):  Use dummy_intent_not_in.
+
 2015-01-12  Janus Weil  <janus@gcc.gnu.org>
 
        Backport from mainline
index 3924905f0eff1233a65798d02d56356435c172d3..a40b891ffdf56cd06fed9ce9bbc88e4a2592cec7 100644 (file)
@@ -1604,11 +1604,40 @@ gfc_check_element_vs_element (gfc_ref *lref, gfc_ref *rref, int n)
   return GFC_DEP_EQUAL;
 }
 
+/* Callback function for checking if an expression depends on a
+   dummy variable which is any other than INTENT(IN).  */
+
+static int
+callback_dummy_intent_not_in (gfc_expr **ep,
+                             int *walk_subtrees ATTRIBUTE_UNUSED,
+                             void *data ATTRIBUTE_UNUSED)
+{
+  gfc_expr *e = *ep;
+
+  if (e->expr_type == EXPR_VARIABLE && e->symtree
+      && e->symtree->n.sym->attr.dummy)
+    return e->symtree->n.sym->attr.intent != INTENT_IN;
+  else
+    return 0;
+}
+
+/* Auxiliary function to check if subexpressions have dummy variables which
+   are not intent(in).
+*/
+
+static bool
+dummy_intent_not_in (gfc_expr **ep)
+{
+  return gfc_expr_walker (ep, callback_dummy_intent_not_in, NULL);
+}
 
 /* Determine if an array ref, usually an array section specifies the
    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.  */
+   contiguous; eg. (:, 1) gives true but (1,:) gives false. 
+   If one of the bounds depends on a dummy variable which is
+   not INTENT(IN), also return false, because the user may
+   have changed the variable.  */
 
 bool
 gfc_full_array_ref_p (gfc_ref *ref, bool *contiguous)
@@ -1672,14 +1701,16 @@ gfc_full_array_ref_p (gfc_ref *ref, bool *contiguous)
          && (!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])))
+                                      ref->u.ar.as->lower[i])
+             || dummy_intent_not_in (&ref->u.ar.start[i])))
        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])))
+                                      ref->u.ar.as->upper[i])
+             || dummy_intent_not_in (&ref->u.ar.end[i])))
        ubound_OK = false;
       /* Check the stride.  */
       if (ref->u.ar.stride[i]
index fde23519a363b05569f01f6b516d07ba71dab4c2..eda05176e06e917740473c1ea1cf0efb0bff6ece 100644 (file)
@@ -1,3 +1,9 @@
+2015-01-24  Thomas Koenig  <tkoenig@netcologne.de>
+
+       Backport from trunk
+       PR fortran/57023
+       * gfortran.dg/internal_pack_15.f90:  New test.
+
 2015-01-20  Marek Polacek  <polacek@redhat.com>
 
        Backport from mainline