From fb42421ef060d7bc2e7f954ce12b0fdc83e57ee6 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Sat, 30 Jul 2016 16:19:14 +0000 Subject: re PR fortran/71730 (ICE when character length specification uses an undefined variable) 2016-07-30 Steven G. Kargl PR fortran/71730 * decl.c (char_len_param_value): Check return value of gfc_reduce_init_expr(). 2016-07-30 Steven G. Kargl PR fortran/71730 * gfortran.dg/pr71730.f90: New test. * gfortran.dg/bounds_check_strlen_2.f90: Fix invalid code. * gfortran.dg/array_constructor_27.f03: Update dg-error message. * gfortran.dg/array_constructor_26.f03: Ditto. From-SVN: r238904 --- gcc/fortran/decl.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'gcc/fortran/decl.c') diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index cf75039..7ff2f0d 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -906,6 +906,7 @@ char_len_param_value (gfc_expr **expr, bool *deferred) goto syntax; else if ((*expr)->expr_type == EXPR_VARIABLE) { + bool t; gfc_expr *e; e = gfc_copy_expr (*expr); @@ -917,7 +918,15 @@ char_len_param_value (gfc_expr **expr, bool *deferred) && e->ref->u.ar.dimen_type[0] == DIMEN_RANGE) goto syntax; - gfc_reduce_init_expr (e); + t = gfc_reduce_init_expr (e); + + if (!t && (e->ts.type == BT_UNKNOWN + && e->symtree->n.sym->attr.untyped == 1 + && e->symtree->n.sym->ns->seen_implicit_none == 1)) + { + gfc_free_expr (e); + goto syntax; + } if ((e->ref && e->ref->type == REF_ARRAY && e->ref->u.ar.type != AR_ELEMENT) -- cgit v1.1