[flang-commits] [flang] d2b339f - [flang] Respect left tab limit with Tn editing after ADVANCE='NO'
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Wed Apr 13 21:46:02 PDT 2022
Author: Peter Klausler
Date: 2022-04-13T21:45:53-07:00
New Revision: d2b339f17683465ecd04e905f60b93aed3502555
URL: https://github.com/llvm/llvm-project/commit/d2b339f17683465ecd04e905f60b93aed3502555
DIFF: https://github.com/llvm/llvm-project/commit/d2b339f17683465ecd04e905f60b93aed3502555.diff
LOG: [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
Added:
Modified:
flang/runtime/connection.h
flang/runtime/io-stmt.cpp
flang/runtime/io-stmt.h
flang/runtime/unit.cpp
flang/runtime/unit.h
Removed:
################################################################################
diff --git a/flang/runtime/connection.h b/flang/runtime/connection.h
index b36f7d1eef36f..c86b6947dbedc 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<std::int64_t> EffectiveRecordLength() const {
diff --git a/flang/runtime/io-stmt.cpp b/flang/runtime/io-stmt.cpp
index 3671f11ecd4d0..caa7d29dc9222 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<DIR>::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 <Direction DIR> int ExternalIoStatementState<DIR>::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 0ed14e5ad6a4d..72d6bf6b3b629 100644
--- a/flang/runtime/io-stmt.h
+++ b/flang/runtime/io-stmt.h
@@ -406,7 +406,6 @@ class ExternalIoStatementBase : public IoStatementBase {
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 2ba4faf23dc3f..e9eae5bd6918b 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 6e1a5ffbac7d8..9b9d78c6a108b 100644
--- a/flang/runtime/unit.h
+++ b/flang/runtime/unit.h
@@ -83,7 +83,6 @@ class ExternalFileUnit : public ConnectionState,
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 &);
More information about the flang-commits
mailing list