===================================================================
@@ -2611,14 +2611,40 @@ scalarized_expr (gfc_expr *e_in, gfc_expr **index,
{
/* Look at full individual sections, like a(:). The first index
is the lbound of a full ref. */
-
+ int j;
gfc_array_ref *ar;
+ gfc_expr *lbound_e;
- ar = gfc_find_array_ref (e_in);
+ lbound_e = gfc_copy_expr (e_in);
+ ar = gfc_find_array_ref (lbound_e);
+
ar->type = AR_FULL;
+ for (j = 0; j < ar->dimen; j++)
+ {
+ gfc_free_expr (ar->start[j]);
+ ar->start[j] = NULL;
+ gfc_free_expr (ar->end[j]);
+ ar->end[j] = NULL;
+ gfc_free_expr (ar->stride[j]);
+ ar->stride[j] = NULL;
+ }
+
+ /* We have to get rid of the shape, if thre is one. Do
+ so by freeing it and calling gfc_resolve to rebuild it,
+ if necessary. */
+
+ if (lbound_e->shape)
+ gfc_free_shape (&(lbound_e->shape), lbound_e->rank);
+
+ lbound_e->rank = ar->dimen;
+
+ gfc_resolve_expr (lbound_e);
+ lbound = get_array_inq_function (GFC_ISYM_LBOUND,
+ lbound_e, i + 1);
}
- lbound = get_array_inq_function (GFC_ISYM_LBOUND, e_in,
- i_index + 1);
+ else
+ lbound = get_array_inq_function (GFC_ISYM_LBOUND, e_in,
+ i_index + 1);
}
ar->dimen_type[i] = DIMEN_ELEMENT;
@@ -2639,6 +2665,8 @@ scalarized_expr (gfc_expr *e_in, gfc_expr **index,
i_index ++;
}
}
+ gfc_free_expr (e_in);
+
return e;
}