aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/runtime
diff options
context:
space:
mode:
authorjb <jb@138bc75d-0d04-0410-961f-82ee72b054a4>2017-11-28 19:28:50 +0000
committerjb <jb@138bc75d-0d04-0410-961f-82ee72b054a4>2017-11-28 19:28:50 +0000
commita8600d84f51d0417f5f5084a1fe45d867f9c018c (patch)
tree4255e7df80923463cf7ce62bf84f31f5f890ab13 /libgfortran/runtime
parent011f5d3ea30fc4404ce75deb172d1b3eeab1dcca (diff)
PR 53796 Improve INQUIRE(RECL=...) handling
The current F2018 draft (N2137) specifies behavior of the RECL= specifier in the INQUIRE statement, where it previously was left as undefined. Namely: - If the unit is not connected, RECL= should be given the value -1. - If the unit is connected with stream access, RECL= should be given the value -2. Further, as PR 53796 describes, the handling of RECL= is poor in other ways as well. When the recl is set to the maximum possible (GFC_INTEGER_8_HUGE / LLONG_MAX), which it does by default except for preconnected units, and when INQUIRE(RECL=) is used with a 4 byte integer, the value is truncated and the 4 byte value is thus -1. Fixing this to generate an error is a lot of work, as currently the truncation is done by the frontend, the library sees only an 8 byte value with no indication that the frontend is going to copy it to a 4 byte one. Instead, this patch does a bit twiddling trick such that the truncated 4 byte value is GFC_INTEGER_4_HUGE while still being 0.99999999 * GFC_INTEGER_8_HUGE which is large enough for all practical purposes. Finally, the patch removes GFORTRAN_DEFAULT_RECL which was used only for preconnected units, and instead uses the same approach as describe above. Regtested on x86_64-pc-linux-gnu, Ok for trunk. gcc/fortran/ChangeLog: 2017-11-28 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/53796 * gfortran.texi: Remove mentions of GFORTRAN_DEFAULT_RECL. libgfortran/ChangeLog: 2017-11-28 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/53796 * io/inquire.c (inquire_via_unit): Set recl to -1 for unconnected units. * io/io.h (default_recl): New variable. * io/open.c (new_unit): Set recl to default_recl for sequential, -2 for stream access. * io/transfer.c (read_block_form): Test against default_recl instead of DEFAULT_RECL. (write_block): Likewise. * io/unit.c (init_units): Calculate max_offset, default_recl. * libgfortran.h (DEFAULT_RECL): Remove. * runtime/environ.c: Remove GFORTRAN_DEFAULT_RECL. gcc/testsuite/ChangeLog: 2017-11-28 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/53796 * gfortran.dg/inquire_recl_f2018.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@255215 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/runtime')
-rw-r--r--libgfortran/runtime/environ.c4
1 files changed, 0 insertions, 4 deletions
diff --git a/libgfortran/runtime/environ.c b/libgfortran/runtime/environ.c
index f0a593e6074..fb9a3c170d5 100644
--- a/libgfortran/runtime/environ.c
+++ b/libgfortran/runtime/environ.c
@@ -208,10 +208,6 @@ static variable variable_table[] = {
/* Print optional plus signs in numbers where permitted */
{ "GFORTRAN_OPTIONAL_PLUS", 0, &options.optional_plus, init_boolean },
- /* Default maximum record length for sequential files */
- { "GFORTRAN_DEFAULT_RECL", DEFAULT_RECL, &options.default_recl,
- init_unsigned_integer },
-
/* Separator to use when writing list output */
{ "GFORTRAN_LIST_SEPARATOR", 0, NULL, init_sep },