[Patch,fortran] PR 24112: Reopen file with status specifier.

Janne Blomqvist jblomqvi@cc.hut.fi
Thu Sep 29 16:44:00 GMT 2005


The standard essentially says that the same file can be opened on the
same unit iff status is either the value it was before or if it is
'old'. Attached patch fixes it.



-- 
Janne Blomqvist
-------------- next part --------------
libgfortran Changelog:

2005-09-29  Janne Blomqvist <jblomqvi@cc.hut.fi>

	PR 24112
	* io/open.c (edit_modes): Check for correct flag.
	
-------------- next part --------------
Index: open.c
===================================================================
RCS file: /cvsroot/gcc/gcc/libgfortran/io/open.c,v
retrieving revision 1.16
diff -p -u -r1.16 open.c
--- open.c	17 Aug 2005 02:48:57 -0000	1.16
+++ open.c	29 Sep 2005 16:33:37 -0000
@@ -120,7 +120,7 @@ edit_modes (gfc_unit * u, unit_flags * f
   /* Complain about attempts to change the unchangeable.  */
 
   if (flags->status != STATUS_UNSPECIFIED &&
-      u->flags.status != flags->position)
+      u->flags.status != flags->status)
     generate_error (ERROR_BAD_OPTION,
 		    "Cannot change STATUS parameter in OPEN statement");
 
-------------- next part --------------
! { dg-do run }
! Test reopening with io status='old'
program iostatus
  open (1, file='foo', status='replace') ! Make sure file exists.
  open (1, file='foo', status='old')
  open (1, file='foo', status='old')
  close (1, status='delete')
end program iostatus


More information about the Gcc-patches mailing list