[flang-commits] [PATCH] D125057: [flang][runtime] BACKSPACE after non-advancing I/O
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Thu May 5 16:26:03 PDT 2022
klausler created this revision.
klausler added a reviewer: vdonaldson.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.
A BACKSPACE statement on a unit after a READ or WRITE with ADVANCE="NO"
must reset the position to the beginning of the record, not to the
beginning of the previous one.
https://reviews.llvm.org/D125057
Files:
flang/runtime/io-stmt.cpp
flang/runtime/unit.cpp
Index: flang/runtime/unit.cpp
===================================================================
--- flang/runtime/unit.cpp
+++ flang/runtime/unit.cpp
@@ -569,6 +569,9 @@
if (IsAfterEndfile()) {
// BACKSPACE after explicit ENDFILE
currentRecordNumber = *endfileRecordNumber;
+ } else if (leftTabLimit) {
+ // BACKSPACE after non-advancing I/O
+ leftTabLimit.reset();
} else {
DoImpliedEndfile(handler);
if (frameOffsetInFile_ + recordOffsetInFrame_ > 0) {
Index: flang/runtime/io-stmt.cpp
===================================================================
--- flang/runtime/io-stmt.cpp
+++ flang/runtime/io-stmt.cpp
@@ -315,6 +315,9 @@
}
if constexpr (DIR == Direction::Input) {
BeginReadingRecord(); // in case there were no I/O items
+ if (mutableModes().nonAdvancing) {
+ unit().leftTabLimit = unit().furthestPositionInRecord;
+ }
if (!mutableModes().nonAdvancing || GetIoStat() == IostatEor) {
FinishReadingRecord();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125057.427488.patch
Type: text/x-patch
Size: 1015 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220505/497a3298/attachment.bin>
More information about the flang-commits
mailing list