re PR fortran/88328 (ICE in resolve_tag_format, at fortran/io.c:1641)

2018-12-22  Steven G. Kargl  <kargl@gcc.gnu.org>

	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  <kargl@gcc.gnu.org>

	PR fortran/88328
	* gfortran.dg/pr88328.f90: New test.

From-SVN: r267367
This commit is contained in:
Steven G. Kargl 2018-12-23 05:18:27 +00:00
parent e2385f4e81
commit 0652a15121
4 changed files with 34 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2018-12-22 Steven G. Kargl <kargl@gcc.gnu.org>
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 <kargl@gcc.gnu.org>
PR fortran/85798

View File

@ -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);

View File

@ -1,3 +1,8 @@
2018-12-22 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/88328
* gfortran.dg/pr88328.f90: New test.
2018-12-21 Jan Hubicka <jh@suse.cz>
* g++.dg/ipa/devirt-30.C: Add dg-do.

View File

@ -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