The attached patch is straight-forward and self explanatory.

Regression tested on x86-64-pc-linux-gnu.  Test case attached.

OK for trunk?


2019-01-31  Jerry DeLisle  <jvdeli...@gcc.gnu.org>

        PR fortran/52564
        * io.c (match_io): Add check for comma after '*' without subsequent
        IO list.

diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c
index fce9228c302..95b30132203 100644
--- a/gcc/fortran/io.c
+++ b/gcc/fortran/io.c
@@ -4172,6 +4172,23 @@ match_io (io_kind k)
 	      else
 		gfc_current_locus = where;
 	    }
+
+	  if (gfc_match_char ('*') == MATCH_YES
+	      && gfc_match_char(',') == MATCH_YES)
+	    {
+	      locus where2 = gfc_current_locus;
+	      if (gfc_match_eos () == MATCH_YES)
+		{
+		  gfc_current_locus = where2;
+		  gfc_error ("Comma after * at %C not allowed without I/O list");
+		  m = MATCH_ERROR;
+		  goto cleanup;
+		}
+	      else
+		gfc_current_locus = where;
+	    }
+	  else
+	    gfc_current_locus = where;
 	}
 
       if (gfc_current_form == FORM_FREE)
! { dg-do compile }
! PR52564 Accepts invalid: Missing I/O list after comma 
program printbug
  print *, 'hello world'
! the following line should not compile:
  print *,  ! { dg-error "not allowed" }
end program

Reply via email to