+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
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 *);
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)
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);
+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
--- /dev/null
+! { 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