From: Steven G. Kargl Date: Sun, 23 Dec 2018 05:18:27 +0000 (+0000) Subject: re PR fortran/88328 (ICE in resolve_tag_format, at fortran/io.c:1641) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0652a1512130cfda8a7ffb192f47bf19c9be2525;p=gcc.git re PR fortran/88328 (ICE in resolve_tag_format, at fortran/io.c:1641) 2018-12-22 Steven G. Kargl PR fortran/88328 * io.c (resolve_tag_format): Add error for zero-sized array. (gfc_resolve_dt): Manipulate gfc_current_locus to get sensible error message locus. 2018-12-22 Steven G. Kargl PR fortran/88328 * gfortran.dg/pr88328.f90: New test. From-SVN: r267367 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 276aad9c14b..d351d50790c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2018-12-22 Steven G. Kargl + + PR fortran/88328 + * io.c (resolve_tag_format): Add error for zero-sized array. + (gfc_resolve_dt): Manipulate gfc_current_locus to get sensible error + message locus. + 2018-12-22 Steven G . Kargl PR fortran/85798 diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index 9c3e6892a07..541e6ef997e 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -1636,6 +1636,12 @@ resolve_tag_format (gfc_expr *e) gfc_expr *r; gfc_char_t *dest, *src; + if (e->value.constructor == NULL) + { + gfc_error ("FORMAT tag at %C cannot be a zero-sized array"); + return false; + } + n = 0; c = gfc_constructor_first (e->value.constructor); len = c->expr->value.character.length; @@ -3245,12 +3251,21 @@ gfc_resolve_dt (gfc_dt *dt, locus *loc) { gfc_expr *e; io_kind k; + locus tmp; /* This is set in any case. */ gcc_assert (dt->dt_io_kind); k = dt->dt_io_kind->value.iokind; - RESOLVE_TAG (&tag_format, dt->format_expr); + tmp = gfc_current_locus; + gfc_current_locus = *loc; + if (!resolve_tag (&tag_format, dt->format_expr)) + { + gfc_current_locus = tmp; + return false; + } + gfc_current_locus = tmp; + RESOLVE_TAG (&tag_rec, dt->rec); RESOLVE_TAG (&tag_spos, dt->pos); RESOLVE_TAG (&tag_advance, dt->advance); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 473d0c8bc96..806b141de78 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-12-22 Steven G. Kargl + + PR fortran/88328 + * gfortran.dg/pr88328.f90: New test. + 2018-12-21 Jan Hubicka * g++.dg/ipa/devirt-30.C: Add dg-do. diff --git a/gcc/testsuite/gfortran.dg/pr88328.f90 b/gcc/testsuite/gfortran.dg/pr88328.f90 new file mode 100644 index 00000000000..cd1c6eb95fa --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr88328.f90 @@ -0,0 +1,6 @@ +! { dg-do compile } +! PR fortran/88328 +program p + character(3), parameter :: a(0) = [character(3)::] + print a ! { dg-error "zero-sized array" } +end