From: Steven G. Kargl Date: Fri, 2 Oct 2015 00:49:28 +0000 (+0000) Subject: re PR fortran/66979 (gfortran internal compiler error with malformed FLUSH statement) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=220ab6b433ee3a360c52032445676758991ed7d9;p=gcc.git re PR fortran/66979 (gfortran internal compiler error with malformed FLUSH statement) 2015-10-01 Steven G. Kargl PR fortran/66979 * io.c (gfc_resolve_filepos): Check for a UNIT number. Add a nearby missing 'return false'. 2015-10-01 Steven G. Kargl PR fortran/66979 gfortran.dg/pr66979.f90: new test. From-SVN: r228364 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 2a306e55f69..9e6f2bdbcd5 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2015-10-01 Steven G. Kargl + + PR fortran/66979 + * io.c (gfc_resolve_filepos): Check for a UNIT number. Add a nearby + missing 'return false'. + 2015-10-01 Steven G. Kargl PR fortran/67616 diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index cff2b689786..e5d68fb60ba 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -2515,12 +2515,21 @@ gfc_resolve_filepos (gfc_filepos *fp) if (!gfc_reference_st_label (fp->err, ST_LABEL_TARGET)) return false; + if (!fp->unit && (fp->iostat || fp->iomsg)) + { + locus where; + where = fp->iostat ? fp->iostat->where : fp->iomsg->where; + gfc_error ("UNIT number missing in statement at %L", &where); + return false; + } + if (fp->unit->expr_type == EXPR_CONSTANT && fp->unit->ts.type == BT_INTEGER && mpz_sgn (fp->unit->value.integer) < 0) { gfc_error ("UNIT number in statement at %L must be non-negative", &fp->unit->where); + return false; } return true; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bf9b3e406f2..ea748b92adc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-10-01 Steven G. Kargl + + PR fortran/66979 + gfortran.dg/pr66979.f90: new test. + 2015-10-01 Steven G. Kargl PR fortran/67616 diff --git a/gcc/testsuite/gfortran.dg/pr66979.f90 b/gcc/testsuite/gfortran.dg/pr66979.f90 new file mode 100644 index 00000000000..c102e91e91d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr66979.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +! PR fortran/66979 +program p + implicit none + integer::i + flush (iostat=i) ! { dg-error "UNIT number missing" } +end program p