Commit 437725af by Thomas Koenig

re PR fortran/87782 (runtime error: load of value 1818451807, which is not a…

re PR fortran/87782 (runtime error: load of value 1818451807, which is not a valid value for type 'expr_t')

2018-11-01  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/87782
	* frontend-passes.c (constant_string_length): If there is a
	substring with a length which cannot be reduced to a constant,
	return NULL.

From-SVN: r265730
parent a5fbc2f3
2018-11-01 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/87782
* frontend-passes.c (constant_string_length): If there is a
substring with a length which cannot be reduced to a constant,
return NULL.
2018-11-01 Paul Thomas <pault@gcc.gnu.org> 2018-11-01 Paul Thomas <pault@gcc.gnu.org>
PR fortran/40196 PR fortran/40196
......
...@@ -638,11 +638,13 @@ constant_string_length (gfc_expr *e) ...@@ -638,11 +638,13 @@ constant_string_length (gfc_expr *e)
return gfc_copy_expr(length); return gfc_copy_expr(length);
} }
/* Return length of substring, if constant. */ /* See if there is a substring. If it has a constant length, return
that and NULL otherwise. */
for (ref = e->ref; ref; ref = ref->next) for (ref = e->ref; ref; ref = ref->next)
{ {
if (ref->type == REF_SUBSTRING if (ref->type == REF_SUBSTRING)
&& gfc_dep_difference (ref->u.ss.end, ref->u.ss.start, &value)) {
if (gfc_dep_difference (ref->u.ss.end, ref->u.ss.start, &value))
{ {
res = gfc_get_constant_expr (BT_INTEGER, gfc_charlen_int_kind, res = gfc_get_constant_expr (BT_INTEGER, gfc_charlen_int_kind,
&e->where); &e->where);
...@@ -651,10 +653,12 @@ constant_string_length (gfc_expr *e) ...@@ -651,10 +653,12 @@ constant_string_length (gfc_expr *e)
mpz_clear (value); mpz_clear (value);
return res; return res;
} }
else
return NULL;
}
} }
/* Return length of char symbol, if constant. */ /* Return length of char symbol, if constant. */
if (e->symtree && e->symtree->n.sym->ts.u.cl if (e->symtree && e->symtree->n.sym->ts.u.cl
&& e->symtree->n.sym->ts.u.cl->length && e->symtree->n.sym->ts.u.cl->length
&& e->symtree->n.sym->ts.u.cl->length->expr_type == EXPR_CONSTANT) && e->symtree->n.sym->ts.u.cl->length->expr_type == EXPR_CONSTANT)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment