From 474175e925a90166e1f4adcc83f9ddfbab1f841b Mon Sep 17 00:00:00 2001 From: Jerry DeLisle Date: Thu, 31 Jan 2019 03:37:16 +0000 Subject: [PATCH] re PR fortran/52564 (Accepts invalid: Missing I/O list after comma) 2019-01-30 Jerry DeLisle PR fortran/52564 * io.c (match_io): Add check for comma after '*' without subsequent IO list. * gfortran.dg/print_2.f90: New test. From-SVN: r268412 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/io.c | 17 +++++++++++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/print_2.f90 | 7 +++++++ 4 files changed, 35 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/print_2.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ac9169a76e6..c78e32af173 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-01-30 Jerry DeLisle + + PR fortran/52564 + * io.c (match_io): Add check for comma after '*' without subsequent + IO list. + 2019-01-30 Dominique d'Humieres PR fortran/52884 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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d14df186b0d..917c13e57a2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-01-30 Jerry DeLisle + + PR fortran/52564 + * gfortran.dg/print_2.f90: New test. + 2019-01-30 Vladimir Makarov PR rtl-optimization/87246 diff --git a/gcc/testsuite/gfortran.dg/print_2.f90 b/gcc/testsuite/gfortran.dg/print_2.f90 new file mode 100644 index 00000000000..4befedf4c22 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/print_2.f90 @@ -0,0 +1,7 @@ +! { 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