I've had this patch in my i386-*-freebsd and x86_64-*-freebsd for more than a week. Several 'gmake check-gfortran' have been run during that time without a regression.
OK for trunk? 2011-10-30 Steven G. Kargl <ka...@gcc.gnu.org> PR fortran/50404 * io.c (gfc_resolve_close): A CLOSE statement requires a unit number. 2011-10-30 Steven G. Kargl <ka...@gcc.gnu.org> PR fortran/50404 * gfortran.dg/no_unit_error_2.f90: New test. -- Steve
Index: fortran/io.c =================================================================== --- fortran/io.c (revision 180687) +++ fortran/io.c (working copy) @@ -2295,6 +2295,12 @@ gfc_resolve_close (gfc_close *close) if (gfc_reference_st_label (close->err, ST_LABEL_TARGET) == FAILURE) return FAILURE; + if (close->unit == NULL) + { + gfc_error ("CLOSE statement at %C requires a UNIT number"); + return FAILURE; + } + if (close->unit->expr_type == EXPR_CONSTANT && close->unit->ts.type == BT_INTEGER && mpz_sgn (close->unit->value.integer) < 0) Index: testsuite/gfortran.dg/no_unit_error_2.f90 =================================================================== --- testsuite/gfortran.dg/no_unit_error_2.f90 (revision 0) +++ testsuite/gfortran.dg/no_unit_error_2.f90 (revision 0) @@ -0,0 +1,4 @@ +! { dg-do compile } +! PR fortran/50404 +close(iostat=i) ! { dg-error "requires a UNIT number" } +end