From: FX <fxcoudert@gmail.com>
To: Harald Anlauf <anlauf@gmx.de>
Cc: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [patch] Fix libfortran/101255, wrong IOSTAT value for FLUSH
Date: Thu, 16 Dec 2021 17:34:01 +0100 [thread overview]
Message-ID: <B39DF7AD-053C-4AEE-B78B-F90180F23A32@gmail.com> (raw)
In-Reply-To: <9a51d5ac-5b23-89fb-05f4-65b4a508d34e@gmx.de>
[-- Attachment #1: Type: text/plain, Size: 301 bytes --]
With correct patch attached, sorry.
--------
Hi,
Bug reported by Tobias at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101255 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101255>
Trivial fix, adding a testcase.
Bootstrapped and regtested on x86_64-pc-linux-gnu.
OK to commit?
FX
[-- Attachment #2: pr101255.patch --]
[-- Type: application/octet-stream, Size: 1415 bytes --]
commit 927ee72bf614d67ec077417039c202a22383c254
Author: Francois-Xavier Coudert <fxcoudert@gmail.com>
Date: 2021-12-16 15:33:17 +0100
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.
diff --git a/gcc/testsuite/gfortran.dg/iostat_5.f90 b/gcc/testsuite/gfortran.dg/iostat_5.f90
new file mode 100644
index 00000000000..aa9d5f104e6
--- /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 == "") call abort
+ if (i >= 0) call abort
+ if (i == IOSTAT_EOR .or. i == IOSTAT_END) call abort
+end
diff --git a/libgfortran/io/file_pos.c b/libgfortran/io/file_pos.c
index 7e71ca577e0..4ed1698f17a 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)
next prev parent reply other threads:[~2021-12-16 16:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-16 14:49 FX
2021-12-16 16:26 ` Harald Anlauf
2021-12-16 16:26 ` Harald Anlauf
2021-12-16 16:34 ` FX [this message]
2021-12-16 16:37 ` Harald Anlauf
2021-12-16 16:37 ` Harald Anlauf
2021-12-16 16:48 ` FX
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=B39DF7AD-053C-4AEE-B78B-F90180F23A32@gmail.com \
--to=fxcoudert@gmail.com \
--cc=anlauf@gmx.de \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).