llvm-capstone/flang/runtime
peter klausler 4d42e16eb8 [flang] runtime: fix problems with I/O around EOF & delimited characters
When a WRITE overwrites an endfile record, we need to forget
that there was an endfile record.  When doing a BACKSPACE
after an explicit ENDFILE statement, the position afterwards
must be upon the endfile record.

Attempts to join list-directed delimited character input across
record boundaries was due to a bad reading of the standard
and has been deleted, now that the requirements are better understood.
This problem would cause a read attempt past EOF if a delimited
character input value was at the end of a record.

It turns out that delimited list-directed (and NAMELIST) character
output is required to emit contiguous doubled instances of the
delimiter character when it appears in the output value.  When
fixed-size records are being emitted, as is the case with internal
output, this is not possible when the problematic character falls
on the last position of a record.  No two other Fortran compilers
do the same thing in this situation so there is no good precedent
to follow.

Because it seems least wrong, with this patch we now emit one copy
of the delimiter as the last character of the current record and
another as the first character of the next record.  (The
second-least-wrong alternative might be to flag a runtime error,
but that seems harsh since it's not an explicit error in the standard,
and the output may not have to be usable later as input anyway.)
Consequently, the output is not suitable for use as list-directed or
NAMELIST input.

If a later standard were to clarify this case, this behavior will of
course change as needed to conform.

Differential Revision: https://reviews.llvm.org/D106695
2021-07-23 18:23:26 -07:00
..
allocatable.cpp [flang] Run-time derived type initialization and destruction 2021-07-20 15:24:16 -07:00
allocatable.h [flang] Run-time derived type initialization and destruction 2021-07-20 15:24:16 -07:00
buffer.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
buffer.h [flang] Fix Boolean flag arguments 2021-04-14 10:19:44 -07:00
c-or-cpp.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
character.cpp [flang] Correct the subscripts used for arguments to character intrinsics 2021-06-16 10:26:25 -07:00
character.h [flang] Remove interfaces for Character[Min|Max][Val|Loc]. NFC 2021-04-28 07:58:06 +00:00
CMakeLists.txt [flang] Run-time derived type initialization and destruction 2021-07-20 15:24:16 -07:00
complex-reduction.c [flang] Implement DOT_PRODUCT in the runtime 2021-05-13 10:40:07 -07:00
complex-reduction.h [flang] Implement DOT_PRODUCT in the runtime 2021-05-13 10:40:07 -07:00
config.h.cmake [flang] Support platforms without strerror_r 2020-03-28 16:46:43 -05:00
connection.cpp [flang] Implement NAMELIST I/O in the runtime 2021-05-06 11:18:36 -07:00
connection.h [flang] Fix "non-advancing" I/O, support $ in FORMAT 2021-06-28 12:18:25 -07:00
copy.cpp [flang] Runtime implementation for default derived type formatted I/O 2021-06-18 10:30:28 -07:00
copy.h [flang] Implement more transformational intrinsic functions in runtime 2021-05-20 13:22:01 -07:00
cpp-type.h [flang] Implement reductions in the runtime 2021-04-01 11:23:50 -07:00
derived-api.cpp [flang] Run-time derived type initialization and destruction 2021-07-20 15:24:16 -07:00
derived-api.h [flang] Run-time derived type initialization and destruction 2021-07-20 15:24:16 -07:00
derived.cpp [flang] Run-time derived type initialization and destruction 2021-07-20 15:24:16 -07:00
derived.h [flang] Run-time derived type initialization and destruction 2021-07-20 15:24:16 -07:00
descriptor-io.cpp [flang] Fix legitimate warning from latest GCC 2021-07-20 11:40:34 -07:00
descriptor-io.h [flang] Run-time derived type initialization and destruction 2021-07-20 15:24:16 -07:00
descriptor.cpp [flang] Run-time derived type initialization and destruction 2021-07-20 15:24:16 -07:00
descriptor.h [flang] Remove now-unused private data member, silence warning 2021-07-20 17:24:39 -07:00
dot-product.cpp [flang] Implement MATMUL in the runtime 2021-05-18 10:59:52 -07:00
edit-input.cpp [flang] runtime: fix problems with I/O around EOF & delimited characters 2021-07-23 18:23:26 -07:00
edit-input.h [flang][msvc] Avoid dependence on long double 2020-10-07 15:12:08 -07:00
edit-output.cpp [flang] runtime: fix problems with I/O around EOF & delimited characters 2021-07-23 18:23:26 -07:00
edit-output.h [flang][msvc] Avoid dependence on long double 2020-10-07 15:12:08 -07:00
entry-names.h [flang] Implement reductions in the runtime 2021-04-01 11:23:50 -07:00
environment.cpp [flang] Implement byte-swapped external unformatted I/O in runtime 2020-07-21 18:14:46 -07:00
environment.h [flang] Implement byte-swapped external unformatted I/O in runtime 2020-07-21 18:14:46 -07:00
extrema.cpp [flang] Implement NORM2 in the runtime 2021-05-07 13:23:21 -07:00
file.cpp [flang] Don't require newline at EOF in unformatted sequential runtime input 2021-07-20 15:25:09 -07:00
file.h [flang] Acquire file accessibility, size, positioning 2020-08-03 16:42:48 -07:00
findloc.cpp [flang] (NFC) Break up flang/runtime/reduction.cpp 2021-04-22 15:24:10 -07:00
format-implementation.h [flang] Fix "non-advancing" I/O, support $ in FORMAT 2021-06-28 12:18:25 -07:00
format.cpp [flang] Implement user-defined derived type runtime I/O 2021-06-28 11:36:19 -07:00
format.h [flang] Fix "non-advancing" I/O, support $ in FORMAT 2021-06-28 12:18:25 -07:00
internal-unit.cpp [flang] External I/O runtime work, repackaged (part 1) 2020-07-02 15:17:26 -07:00
internal-unit.h [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
io-api.cpp [flang] Fix "non-advancing" I/O, support $ in FORMAT 2021-06-28 12:18:25 -07:00
io-api.h [flang] Implement NAMELIST I/O in the runtime 2021-05-06 11:18:36 -07:00
io-error.cpp [flang] Implement user-defined derived type runtime I/O 2021-06-28 11:36:19 -07:00
io-error.h [flang] Implement user-defined derived type runtime I/O 2021-06-28 11:36:19 -07:00
io-stmt.cpp [flang] Fix "non-advancing" I/O, support $ in FORMAT 2021-06-28 12:18:25 -07:00
io-stmt.h [flang] Runtime: Reset list-directed input state for each NAMELIST item 2021-07-23 18:21:33 -07:00
iostat.cpp [flang] Define new runtime error IOSTAT values (I/O runtime work part 4) 2020-07-03 12:41:33 -07:00
iostat.h [flang] Define new runtime error IOSTAT values (I/O runtime work part 4) 2020-07-03 12:41:33 -07:00
ISO_Fortran_binding.cpp [flang] Add clang-tidy check for braces around if 2021-06-16 09:13:53 +00:00
lock.h [flang] More Fortran runtime support for CHARACTER operations 2020-06-17 15:51:48 -07:00
magic-numbers.h [flang] Implement runtime support for basic ALLOCATE/DEALLOCATE 2020-11-12 10:21:40 -08:00
main.cpp [flang] Implement byte-swapped external unformatted I/O in runtime 2020-07-21 18:14:46 -07:00
main.h [flang] Implement byte-swapped external unformatted I/O in runtime 2020-07-21 18:14:46 -07:00
matmul.cpp [flang] Implement MATMUL in the runtime 2021-05-18 10:59:52 -07:00
matmul.h [flang] Implement MATMUL in the runtime 2021-05-18 10:59:52 -07:00
memory.cpp [flang] Reformat with latest clang-format and .clang-format 2020-03-28 21:00:16 -07:00
memory.h [flang] Implement runtime support for INQUIRE statements 2020-08-03 17:15:08 -07:00
misc-intrinsic.cpp [flang] Runtime API for data pointers 2021-07-19 08:23:06 -07:00
misc-intrinsic.h [flang] TRANSFER() intrinsic function 2021-04-02 10:41:37 -07:00
namelist.cpp [flang] Runtime: Reset list-directed input state for each NAMELIST item 2021-07-23 18:21:33 -07:00
namelist.h [flang] Implement NAMELIST I/O in the runtime 2021-05-06 11:18:36 -07:00
numeric.cpp [flang] Define missing & needed IEEE_ARITHMETIC symbols 2021-04-19 11:44:43 -07:00
numeric.h [flang] Define missing & needed IEEE_ARITHMETIC symbols 2021-04-19 11:44:43 -07:00
pgmath.h.inc [flang] Rework host runtime folding and enable REAL(2) folding with it. 2020-10-14 16:40:44 +02:00
pointer.cpp [flang] Run-time derived type initialization and destruction 2021-07-20 15:24:16 -07:00
pointer.h [flang] Runtime API for data pointers 2021-07-19 08:23:06 -07:00
product.cpp [flang] (NFC) Break up flang/runtime/reduction.cpp 2021-04-22 15:24:10 -07:00
random.cpp [flang] Fixed simple typo in runtime code 2021-06-10 11:14:25 -06:00
random.h [flang] RANDOM_NUMBER, RANDOM_SEED, RANDOM_INIT in runtime 2021-04-09 17:03:11 -07:00
reduction-templates.h [flang] (NFC) Break up flang/runtime/reduction.cpp 2021-04-22 15:24:10 -07:00
reduction.cpp [flang] Implement runtime for IALL & IANY 2021-06-16 14:54:36 -07:00
reduction.h [flang] Implement runtime for IALL & IANY 2021-06-16 14:54:36 -07:00
stat.cpp [flang] Update DE/ALLOCATE statement runtime message processing 2021-03-12 15:42:06 -08:00
stat.h [flang] Update DE/ALLOCATE statement runtime message processing 2021-03-12 15:42:06 -08:00
stop.cpp [flang] Extend runtime API for PAUSE to allow a stop code 2020-10-01 17:20:11 -07:00
stop.h [flang] Extend runtime API for PAUSE to allow a stop code 2020-10-01 17:20:11 -07:00
sum.cpp [flang] Use a "double-double" accumulator in SUM 2021-06-16 14:29:39 -07:00
terminator.cpp [flang] Fix race condition in runtime 2021-05-06 11:09:30 -07:00
terminator.h [flang] Implement IPARITY, PARITY, and FINDLOC reductions 2021-04-20 12:25:42 -07:00
time-intrinsic.cpp [flang] Add POSIX implementation for CPU_TIME 2021-06-14 09:41:11 +00:00
time-intrinsic.h [flang] Add runtime interface for SYSTEM_CLOCK 2021-06-29 08:25:01 +00:00
tools.cpp [flang] Implement user-defined derived type runtime I/O 2021-06-28 11:36:19 -07:00
tools.h [flang] Runtime implementation for default derived type formatted I/O 2021-06-18 10:30:28 -07:00
transformational.cpp [flang] Implement the runtime portion of the CSHIFT intrinsic 2021-07-21 13:39:21 -07:00
transformational.h Change the flang reshape runtime routine interface to use a result 2021-06-24 17:05:12 -07:00
type-code.cpp [flang] Implement reductions in the runtime 2021-04-01 11:23:50 -07:00
type-code.h [flang] Correct TypeCode::IsLogical() 2021-04-12 12:57:22 -07:00
type-info.cpp [flang] Two tweaks to mollify buildbots 2021-07-20 19:42:05 -07:00
type-info.h [flang] Run-time derived type initialization and destruction 2021-07-20 15:24:16 -07:00
unit-map.cpp [flang] Fix "non-advancing" I/O, support $ in FORMAT 2021-06-28 12:18:25 -07:00
unit-map.h [flang] Implement runtime support for INQUIRE statements 2020-08-03 17:15:08 -07:00
unit.cpp [flang] runtime: fix problems with I/O around EOF & delimited characters 2021-07-23 18:23:26 -07:00
unit.h [flang] Fix "non-advancing" I/O, support $ in FORMAT 2021-06-28 12:18:25 -07:00