Fix FLUSH IOSTAT value

PR libfortran/101255

libgfortran/ChangeLog:

	* io/file_pos.c: Fix error code.

gcc/testsuite/ChangeLog:

	* gfortran.dg/iostat_5.f90: New file.
This commit is contained in:
Francois-Xavier Coudert 2021-12-16 15:33:17 +01:00 committed by François-Xavier Coudert
parent 3f624a624a
commit c14f38d429
2 changed files with 17 additions and 1 deletions

View File

@ -0,0 +1,16 @@
! PR libfortran/101255
! { dg-do run }
program test
use ISO_FORTRAN_ENV, only: IOSTAT_EOR, IOSTAT_END
implicit none
character(len=50) :: err
integer :: i
err = ""
flush(99, iostat=i, iomsg=err)
if (err == "") stop 1
if (i >= 0) stop 2
if (i == IOSTAT_EOR .or. i == IOSTAT_END) stop 3
end

View File

@ -527,7 +527,7 @@ st_flush (st_parameter_filepos *fpp)
}
else
/* FLUSH on unconnected unit is illegal: F95 std., 9.3.5. */
generate_error (&fpp->common, LIBERROR_BAD_OPTION,
generate_error (&fpp->common, -LIBERROR_BAD_UNIT,
"Specified UNIT in FLUSH is not connected");
if (needs_unlock)