aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>2021-12-16 15:33:17 +0100
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2021-12-16 17:46:28 +0100
commitc14f38d4292ec22462a4080841d526f87428130a (patch)
treeb8381f8fd9f6a968bd2d4f181be97af81739c761
parent3f624a624a137860e080fc959d7467a76aab263d (diff)
downloadgcc-c14f38d4292ec22462a4080841d526f87428130a.zip
gcc-c14f38d4292ec22462a4080841d526f87428130a.tar.gz
gcc-c14f38d4292ec22462a4080841d526f87428130a.tar.bz2
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.
-rw-r--r--gcc/testsuite/gfortran.dg/iostat_5.f9016
-rw-r--r--libgfortran/io/file_pos.c2
2 files changed, 17 insertions, 1 deletions
diff --git a/gcc/testsuite/gfortran.dg/iostat_5.f90 b/gcc/testsuite/gfortran.dg/iostat_5.f90
new file mode 100644
index 0000000..1e72dfd
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/iostat_5.f90
@@ -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
diff --git a/libgfortran/io/file_pos.c b/libgfortran/io/file_pos.c
index 7e71ca5..4ed1698 100644
--- a/libgfortran/io/file_pos.c
+++ b/libgfortran/io/file_pos.c
@@ -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)