===================================================================
@@ -2845,7 +2845,7 @@ match_filepos (gfc_statement st, gfc_exec_op op)
m = match_file_element (fp);
if (m == MATCH_ERROR)
- goto done;
+ goto syntax;
if (m == MATCH_NO)
{
m = gfc_match_expr (&fp->unit);
===================================================================
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! PR fortran/91587
+! Code contributed by Gerhard Steinmetz
+program p
+ backspace(err=!) ! { dg-error "Syntax error in" }
+ flush(err=!) ! { dg-error "Syntax error in" }
+ rewind(err=!) ! { dg-error "Syntax error in" }
+end
+
+subroutine bar ! An other matcher runs, and gives a different error.
+ endfile(err=!) ! { dg-error "Expecting END" }
+end