From: Janne Blomqvist Date: Wed, 7 Aug 2019 07:34:10 +0000 (+0300) Subject: PR 53796 Make inquire(file=, recl=) conform to F2018 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4047bab96dfc6bcea64a12b428f40d2f7a77ccbb;p=gcc.git PR 53796 Make inquire(file=, recl=) conform to F2018 In my original patch to fix PR 53796 I forgot to fix the behavior for unconnected units when inquiring via filename. This patch fixes that. Regtested on x86_64-pc-linux-gnu, committed as obvious. libgfortran/ChangeLog: 2019-08-07 Janne Blomqvist PR fortran/53796 * io/inquire.c (inquire_via_filename): Set recl to -1 for unconnected units. gcc/testsuite/ChangeLog: 2019-08-07 Janne Blomqvist PR fortran/53796 * gfortran.dg/inquire_recl_f2018.f90: Test for unconnected unit with inquire via filename. From-SVN: r274160 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d524f72b4d2..1d412b60e5d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-08-07 Janne Blomqvist + + PR fortran/53796 + * gfortran.dg/inquire_recl_f2018.f90: Test for unconnected unit + with inquire via filename. + 2019-08-07 Jakub Jelinek * c-c++-common/gomp/target-data-1.c (foo): Use use_device_addr clause diff --git a/gcc/testsuite/gfortran.dg/inquire_recl_f2018.f90 b/gcc/testsuite/gfortran.dg/inquire_recl_f2018.f90 index b744e920f7b..dfb4092a45f 100644 --- a/gcc/testsuite/gfortran.dg/inquire_recl_f2018.f90 +++ b/gcc/testsuite/gfortran.dg/inquire_recl_f2018.f90 @@ -39,4 +39,11 @@ program inqrecl if (r /= -2) then STOP 5 end if + + ! Also inquire by filename for a non-opened unit is considered + ! unconnected similar to the first test. + inquire(file='unconnectedfile.txt', recl=r) + if (r /= -1) then + stop 6 + end if end program inqrecl diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index b4e3fe73282..447ed5a42c7 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +2019-08-07 Janne Blomqvist + + PR fortran/53796 + * io/inquire.c (inquire_via_filename): Set recl to -1 for + unconnected units. + 2019-07-21 Thomas König PR libfortran/91030 diff --git a/libgfortran/io/inquire.c b/libgfortran/io/inquire.c index 05cfc14233f..c2174d0a307 100644 --- a/libgfortran/io/inquire.c +++ b/libgfortran/io/inquire.c @@ -706,7 +706,9 @@ inquire_via_filename (st_parameter_inquire *iqp) } if ((cf & IOPARM_INQUIRE_HAS_RECL_OUT) != 0) - *iqp->recl_out = 0; + /* F2018 (N2137) 12.10.2.26: If there is no connection, recl is + assigned the value -1. */ + *iqp->recl_out = -1; if ((cf & IOPARM_INQUIRE_HAS_NEXTREC) != 0) *iqp->nextrec = 0;