re PR fortran/88249 (ICE in gfc_resolve_filepos, at fortran/io.c:2853)

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

	PR fortran/88249
	* gfortran.h: Update prototype for gfc_resolve_filepos().
	* io.c (gfc_resolve_filepos): Check for UNIT number if ERR= is present.
	Use passed in locus for error message.
	* resolve.c (gfc_resolve_code): Pass locus in gfc_resolve_filepos()
	call.

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

	PR fortran/88249
	* gfortran.dg/pr88249.f90: New test.

From-SVN: r267035
This commit is contained in:
Steven G. Kargl 2018-12-11 23:13:19 +00:00
parent 3b31a90608
commit 3d07fb21d2
6 changed files with 29 additions and 9 deletions

View File

@ -1,3 +1,12 @@
2018-12-11 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/88249
* gfortran.h: Update prototype for gfc_resolve_filepos().
* io.c (gfc_resolve_filepos): Check for UNIT number if ERR= is present.
Use passed in locus for error message.
* resolve.c (gfc_resolve_code): Pass locus in gfc_resolve_filepos()
call.
2018-12-10 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/97922

View File

@ -3395,7 +3395,7 @@ bool gfc_resolve_open (gfc_open *);
void gfc_free_close (gfc_close *);
bool gfc_resolve_close (gfc_close *);
void gfc_free_filepos (gfc_filepos *);
bool gfc_resolve_filepos (gfc_filepos *);
bool gfc_resolve_filepos (gfc_filepos *, locus *);
void gfc_free_inquire (gfc_inquire *);
bool gfc_resolve_inquire (gfc_inquire *);
void gfc_free_dt (gfc_dt *);

View File

@ -2849,22 +2849,21 @@ cleanup:
bool
gfc_resolve_filepos (gfc_filepos *fp)
gfc_resolve_filepos (gfc_filepos *fp, locus *where)
{
RESOLVE_TAG (&tag_unit, fp->unit);
RESOLVE_TAG (&tag_iostat, fp->iostat);
RESOLVE_TAG (&tag_iomsg, fp->iomsg);
if (!gfc_reference_st_label (fp->err, ST_LABEL_TARGET))
return false;
if (!fp->unit && (fp->iostat || fp->iomsg))
if (!fp->unit && (fp->iostat || fp->iomsg || fp->err))
{
locus where;
where = fp->iostat ? fp->iostat->where : fp->iomsg->where;
gfc_error ("UNIT number missing in statement at %L", &where);
gfc_error ("UNIT number missing in statement at %L", where);
return false;
}
if (!gfc_reference_st_label (fp->err, ST_LABEL_TARGET))
return false;
if (fp->unit->expr_type == EXPR_CONSTANT
&& fp->unit->ts.type == BT_INTEGER
&& mpz_sgn (fp->unit->value.integer) < 0)

View File

@ -11545,7 +11545,7 @@ start:
case EXEC_ENDFILE:
case EXEC_REWIND:
case EXEC_FLUSH:
if (!gfc_resolve_filepos (code->ext.filepos))
if (!gfc_resolve_filepos (code->ext.filepos, &code->loc))
break;
resolve_branch (code->ext.filepos->err, code);

View File

@ -1,3 +1,8 @@
2018-12-11 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/88249
* gfortran.dg/pr88249.f90: New test.
2018-12-11 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/80520

View File

@ -0,0 +1,7 @@
! { dg-do compile }
program p
backspace (err=1) ! { dg-error "UNIT number missing" }
endfile (err=1) ! { dg-error "UNIT number missing" }
flush (err=1) ! { dg-error "UNIT number missing" }
rewind (err=1) ! { dg-error "UNIT number missing" }
end