Commit aeb8c028 by Jakub Jelinek

re PR fortran/84065 (string_1.f90 fails since r256944)

	PR fortran/84065
	* decl.c (add_init_expr_to_sym): Ignore initializers for too large
	lengths.

From-SVN: r257121
parent d76ba10d
2018-01-27 Jakub Jelinek <jakub@redhat.com>
PR fortran/84065
* decl.c (add_init_expr_to_sym): Ignore initializers for too large
lengths.
2018-01-26 Damian Rouson <damian@sourceryinstitute.org>
Alessandro Fanfarillo <fanfarillo.gcc@gmail.com>
Soren Rasmussen <s.c.rasmussen@gmail.com>
......
......@@ -1757,7 +1757,15 @@ add_init_expr_to_sym (const char *name, gfc_expr **initp, locus *var_locus)
if (!gfc_specification_expr (sym->ts.u.cl->length))
return false;
HOST_WIDE_INT len = gfc_mpz_get_hwi (sym->ts.u.cl->length->value.integer);
int k = gfc_validate_kind (BT_INTEGER, gfc_charlen_int_kind,
false);
/* resolve_charlen will complain later on if the length
is too large. Just skeep the initialization in that case. */
if (mpz_cmp (sym->ts.u.cl->length->value.integer,
gfc_integer_kinds[k].huge) <= 0)
{
HOST_WIDE_INT len
= gfc_mpz_get_hwi (sym->ts.u.cl->length->value.integer);
if (init->expr_type == EXPR_CONSTANT)
gfc_set_constant_character_len (len, init, -1);
......@@ -1768,7 +1776,8 @@ add_init_expr_to_sym (const char *name, gfc_expr **initp, locus *var_locus)
/* Build a new charlen to prevent simplification from
deleting the length before it is resolved. */
init->ts.u.cl = gfc_new_charlen (gfc_current_ns, NULL);
init->ts.u.cl->length = gfc_copy_expr (sym->ts.u.cl->length);
init->ts.u.cl->length
= gfc_copy_expr (sym->ts.u.cl->length);
for (c = gfc_constructor_first (init->value.constructor);
c; c = gfc_constructor_next (c))
......@@ -1776,6 +1785,7 @@ add_init_expr_to_sym (const char *name, gfc_expr **initp, locus *var_locus)
}
}
}
}
/* If sym is implied-shape, set its upper bounds from init. */
if (sym->attr.flavor == FL_PARAMETER && sym->attr.dimension
......
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