Patchwork PR fortran/50404 -- CLOSE requires unit number

login
register
mail settings
Submitter Steve Kargl
Date Oct. 30, 2011, 11:50 p.m.
Message ID <20111030235000.GA40903@troutmask.apl.washington.edu>
Download mbox | patch
Permalink /patch/122694/
State New
Headers show

Comments

Steve Kargl - Oct. 30, 2011, 11:50 p.m.
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  <kargl@gcc.gnu.org>

	PR fortran/50404
	* io.c (gfc_resolve_close): A CLOSE statement requires a unit number.

2011-10-30  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/50404
	* gfortran.dg/no_unit_error_2.f90: New test.
jerry DeLisle - Oct. 31, 2011, 2:05 a.m.
On 10/30/2011 07:50 PM, Steve Kargl wrote:
> 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?
>
OK, thanks for patch.

Jerry

Patch

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