From: Peter Klausler Date: Thu, 31 Mar 2022 23:46:02 +0000 (-0700) Subject: [flang] Respect left tab limit with Tn editing after ADVANCE='NO' X-Git-Tag: upstream/15.0.7~10474 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d2b339f17683465ecd04e905f60b93aed3502555;p=platform%2Fupstream%2Fllvm.git [flang] Respect left tab limit with Tn editing after ADVANCE='NO' Correct the implementation of non-advancing I/O after some testing to ensure that T tab edit descriptors are not allowed to back up into positions of a record prior to where it stood at the beginning of the I/O statement. Differential Revision: https://reviews.llvm.org/D123709 --- diff --git a/flang/runtime/connection.h b/flang/runtime/connection.h index b36f7d1..c86b694 100644 --- a/flang/runtime/connection.h +++ b/flang/runtime/connection.h @@ -47,7 +47,6 @@ struct ConnectionState : public ConnectionAttributes { void BeginRecord() { positionInRecord = 0; furthestPositionInRecord = 0; - leftTabLimit.reset(); } std::optional EffectiveRecordLength() const { diff --git a/flang/runtime/io-stmt.cpp b/flang/runtime/io-stmt.cpp index 3671f11..caa7d29 100644 --- a/flang/runtime/io-stmt.cpp +++ b/flang/runtime/io-stmt.cpp @@ -199,17 +199,6 @@ MutableModes &ExternalIoStatementBase::mutableModes() { return unit_.modes; } ConnectionState &ExternalIoStatementBase::GetConnectionState() { return unit_; } -void ExternalIoStatementBase::CompleteOperation() { - if (!completedOperation()) { - if (mutableModes().nonAdvancing) { - unit_.leftTabLimit = unit_.furthestPositionInRecord; - } else { - unit_.leftTabLimit.reset(); - } - IoStatementBase::CompleteOperation(); - } -} - int ExternalIoStatementBase::EndIoStatement() { CompleteOperation(); auto result{IoStatementBase::EndIoStatement()}; @@ -330,12 +319,15 @@ void ExternalIoStatementState::CompleteOperation() { FinishReadingRecord(); } } else { - if (!mutableModes().nonAdvancing) { + if (mutableModes().nonAdvancing) { + unit().leftTabLimit = unit().furthestPositionInRecord; + } else { + unit().leftTabLimit.reset(); unit().AdvanceRecord(*this); } unit().FlushIfTerminal(*this); } - return ExternalIoStatementBase::CompleteOperation(); + return IoStatementBase::CompleteOperation(); } template int ExternalIoStatementState::EndIoStatement() { @@ -1013,7 +1005,7 @@ void ExternalMiscIoStatementState::CompleteOperation() { ext.Rewind(*this); break; } - return ExternalIoStatementBase::CompleteOperation(); + return IoStatementBase::CompleteOperation(); } int ExternalMiscIoStatementState::EndIoStatement() { diff --git a/flang/runtime/io-stmt.h b/flang/runtime/io-stmt.h index 0ed14e5..72d6bf6 100644 --- a/flang/runtime/io-stmt.h +++ b/flang/runtime/io-stmt.h @@ -406,7 +406,6 @@ public: ExternalFileUnit &unit() { return unit_; } MutableModes &mutableModes(); ConnectionState &GetConnectionState(); - void CompleteOperation(); int EndIoStatement(); ExternalFileUnit *GetExternalFileUnit() const { return &unit_; } diff --git a/flang/runtime/unit.cpp b/flang/runtime/unit.cpp index 2ba4faf..e9eae5b 100644 --- a/flang/runtime/unit.cpp +++ b/flang/runtime/unit.cpp @@ -410,11 +410,6 @@ bool ExternalFileUnit::SetVariableFormattedRecordLength() { return false; } -void ExternalFileUnit::SetLeftTabLimit() { - leftTabLimit = furthestPositionInRecord; - positionInRecord = furthestPositionInRecord; -} - bool ExternalFileUnit::BeginReadingRecord(IoErrorHandler &handler) { RUNTIME_CHECK(handler, direction_ == Direction::Input); if (!beganReadingRecord_) { diff --git a/flang/runtime/unit.h b/flang/runtime/unit.h index 6e1a5ff..9b9d78c 100644 --- a/flang/runtime/unit.h +++ b/flang/runtime/unit.h @@ -83,7 +83,6 @@ public: const char *, std::size_t, std::size_t elementBytes, IoErrorHandler &); bool Receive(char *, std::size_t, std::size_t elementBytes, IoErrorHandler &); std::size_t GetNextInputBytes(const char *&, IoErrorHandler &); - void SetLeftTabLimit(); bool BeginReadingRecord(IoErrorHandler &); void FinishReadingRecord(IoErrorHandler &); bool AdvanceRecord(IoErrorHandler &);