[gfortran] patch for pr16597

Steven Bosscher stevenb@suse.de
Thu Aug 26 08:45:00 GMT 2004


On Thursday 26 August 2004 04:33, Bud Davis wrote:
> 2004-08-25  Bud Davis  <bdavis9659@comcast.net>
>
> 	PR fortran/16597
> 	* io/io.h (gfc_unit): added mode to unit structure.
> 	* io/transfer.c (data_transfer_init): flush if a write then
>  	read is done on a unit (direct access files).
>
>
> !pr 16597

Can you add a comment here that this is really a library test?  I'd
like to start working a bit on a library test suite soonish.


>       program gfbug4
>       implicit none
>
>       integer      strlen
>       parameter    (strlen = 4)
>
>       integer      iunit
>       character    string *4
>
>       iunit = 99
>       open (UNIT=iunit,FORM='unformatted',ACCESS='direct',RECL=strlen)
>       write (iunit, rec=1) 'ABCD'
>       read (iunit, rec=1) string
>       close (iunit)
>       if (string.ne.'ABCD') call abort
>
>       open (UNIT=iunit,FORM='unformatted',ACCESS='direct',
>      $      STATUS='scratch',RECL=strlen)
>       write (iunit, rec=1) 'ABCD'
>       read (iunit, rec=1) string
>       close (iunit)
>       if (string.ne.'ABCD') call abort
>       end


> Index: gcc/libgfortran/io/io.h
> ===================================================================
> RCS file: /cvs/gcc/gcc/libgfortran/io/io.h,v
> retrieving revision 1.8
> diff -c -3 -p -r1.8 io.h
> *** gcc/libgfortran/io/io.h	23 Aug 2004 14:28:31 -0000	1.8
> --- gcc/libgfortran/io/io.h	26 Aug 2004 02:18:07 -0000
> *************** typedef struct gfc_unit
> *** 271,276 ****
> --- 271,277 ----
>     { NO_ENDFILE, AT_ENDFILE, AFTER_ENDFILE }
>     endfile;
>
> +   int mode;

It's an "enum {READING, WRITING} mode;" in global_t, so why not make
it a typedef and use it in gfc_unit and global_t?

Otherwise this is OK.  I just wonder if we still need the mode in the
(rather ugly) global_t at all if we already record it for each unit.

Gr.
Steven




More information about the Fortran mailing list