+2019-01-17 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR fortran/88871
+ * resolve.c (resolve_ref): Fix logic for removal of
+ reference.
+
2019-01-19 Jakub Jelinek <jakub@redhat.com>
PR fortran/88902
int current_part_dimension, n_components, seen_part_dimension;
gfc_ref *ref, **prev;
bool equal_length;
+ bool breakout;
for (ref = expr->ref; ref; ref = ref->next)
if (ref->type == REF_ARRAY && ref->u.ar.as == NULL)
break;
}
-
- for (ref = expr->ref, prev = &expr->ref; ref; prev = &ref->next, ref = ref->next)
- switch (ref->type)
+ breakout = false;
+ for (prev = &expr->ref; !breakout && *prev != NULL; prev = &(*prev)->next)
+ switch ((*prev)->type)
{
case REF_ARRAY:
- if (!resolve_array_ref (&ref->u.ar))
+ if (!resolve_array_ref (&(*prev)->u.ar))
return false;
break;
case REF_SUBSTRING:
equal_length = false;
- if (!resolve_substring (ref, &equal_length))
+ if (!resolve_substring (*prev, &equal_length))
return false;
if (expr->expr_type != EXPR_SUBSTRING && equal_length)
{
/* Remove the reference and move the charlen, if any. */
+ ref = *prev;
*prev = ref->next;
ref->next = NULL;
expr->ts.u.cl = ref->u.ss.length;
ref->u.ss.length = NULL;
gfc_free_ref_list (ref);
+ if (*prev == NULL)
+ breakout = true;
}
break;
}