From: Jerry DeLisle Date: Sun, 18 Feb 2018 15:32:39 +0000 (+0000) Subject: re PR fortran/84412 (Erroneous "Inquire statement identifies an internal file" error) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d5efbf3fd5e1b872524dfa2439e5163decf1614f;p=gcc.git re PR fortran/84412 (Erroneous "Inquire statement identifies an internal file" error) 2018-02-18 Jerry DeLisle PR libgfortran/84412 * io/transfer.c (finalize_transfer): After completng an internal unit I/O operation, clear internal_unit_kind. From-SVN: r257791 --- diff --git a/gcc/testsuite/gfortran.dg/inquire_18.f90 b/gcc/testsuite/gfortran.dg/inquire_18.f90 new file mode 100644 index 00000000000..9829688225b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/inquire_18.f90 @@ -0,0 +1,11 @@ +! { dg-do run } +! PR84412 Wrong "Inquire statement identifies an internal file" error +program bug + implicit none + integer :: i + character(len=1) :: s + write (s,'(i1)') 0 + open(newUnit=i,file='inquire_18.txt',status='unknown') + inquire(unit=i) + close(i, status="delete") +end program bug diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 2220ec2bae6..20a13e46a4f 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +2018-02-18 Jerry DeLisle + + PR libgfortran/84412 + * io/transfer.c (finalize_transfer): After completng an internal unit + I/O operation, clear internal_unit_kind. + 2018-02-12 Thomas Koenig * libgfortran.h (GFC_ARRAY_DESCRIPTOR): Remove dimension diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index 8bc828c0214..df33bed1561 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -3993,6 +3993,10 @@ finalize_transfer (st_parameter_dt *dtp) if (dtp->u.p.unit_is_internal) { + /* The unit structure may be reused later so clear the + internal unit kind. */ + dtp->u.p.current_unit->internal_unit_kind = 0; + fbuf_destroy (dtp->u.p.current_unit); if (dtp->u.p.current_unit && (dtp->u.p.current_unit->child_dtio == 0)