From b0ef000d4a799217cd0030ea37b59b2ea2a34a9f Mon Sep 17 00:00:00 2001 From: bdavis <bdavis@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Thu, 2 Dec 2004 04:13:21 +0000 Subject: [PATCH] 2004-12-02 Bud Davis <bdavis9659@comcast.net> * io/inquire.c (inquire_via_unit): do not allow a direct access file to be opened for sequential I/O. * gfortran.dg/inquire.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@91610 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gfortran.dg/inquire.f90 | 11 +++++++++++ libgfortran/ChangeLog | 5 +++++ libgfortran/io/inquire.c | 9 +++++++-- 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/inquire.f90 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5a5d84a7f15b..2db19aafe496 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2004-12-02 Bud Davis <bdavis9659@comcast.net> + + * gfortran.dg/inquire.f90: New test. + 2004-12-01 Janis Johnson <janis187@us.ibm.com> * lib/gcc-dg.exp (dg-process-target): Wrapper for dg function to diff --git a/gcc/testsuite/gfortran.dg/inquire.f90 b/gcc/testsuite/gfortran.dg/inquire.f90 new file mode 100644 index 000000000000..9f3b72532af9 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/inquire.f90 @@ -0,0 +1,11 @@ +! { dg-do run } +! check to see that you cannot open a direct access file +! for sequential i/o. +! derived from NIST test fm910.for + IMPLICIT NONE + CHARACTER*10 D4VK + OPEN(UNIT=7, ACCESS='DIRECT',RECL=132,STATUS='SCRATCH') + INQUIRE(UNIT=7,SEQUENTIAL=D4VK) + CLOSE(UNIT=7,STATUS='DELETE') + IF (D4VK.NE.'NO') CALL ABORT + END diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 179ed9bf991f..e90c0faa47e8 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,8 @@ +2004-12-02 Bud Davis <bdavis9659@comcast.net> + + * io/inquire.c (inquire_via_unit): do not allow a direct access + file to be opened for sequential I/O. + 2004-12-02 Steven G. Kargl <kargls@comcast.net> Paul Brook <paul@codesourcery.com> diff --git a/libgfortran/io/inquire.c b/libgfortran/io/inquire.c index 36957dde58f3..a93f99dc1704 100644 --- a/libgfortran/io/inquire.c +++ b/libgfortran/io/inquire.c @@ -73,8 +73,13 @@ inquire_via_unit (gfc_unit * u) if (ioparm.sequential != NULL) { - p = (u == NULL) ? inquire_sequential (NULL, 0) : - inquire_sequential (u->file, u->file_len); + /* disallow an open direct access file to be accessed + sequentially */ + if (u->flags.access==ACCESS_DIRECT) + p = "NO"; + else + p = (u == NULL) ? inquire_sequential (NULL, 0) : + inquire_sequential (u->file, u->file_len); cf_strcpy (ioparm.sequential, ioparm.sequential_len, p); } -- GitLab