PR libfortran/101255
libgfortran/ChangeLog:
* io/file_pos.c: Fix error code.
gcc/testsuite/ChangeLog:
* gfortran.dg/iostat_5.f90: New file.
--- /dev/null
+! 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
}
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)