[flang] Allow write after non advancing read in IO runtime
authorJean Perier <jperier@nvidia.com>
Tue, 16 Nov 2021 13:52:35 +0000 (14:52 +0100)
committerJean Perier <jperier@nvidia.com>
Tue, 16 Nov 2021 13:53:39 +0000 (14:53 +0100)
commit2e65c8e8db1887a39c9140b75a9f5bb892ddd93f
treebf5e07945fa8639ffcf2076b4bd79899671e3524
parent422cf2b506c1240def78b9a5e5b7f32abbcff243
[flang] Allow write after non advancing read in IO runtime

1. To avoid overwriting the part of the record read in the non advancing read,
the furtherPositionInRecord field must be set to the max of the
furtherPositionInRecord and the positionInRecord at the beginning of the
IO write.

2. To allow any further read to succeed after the write, the unit
beganReadingRecord_ must be set to false when resetting the recordLength
during the write, otherwise, recordLength will not be computed in further
read and an assert is hit (at unit.cpp(398)).

The added unit test exercises both of these scenarios.

Differential Revision: https://reviews.llvm.org/D113740
flang/runtime/io-stmt.cpp
flang/runtime/unit.cpp
flang/unittests/Runtime/ExternalIOTest.cpp