[flang-commits] [flang] [flang][runtime] Don't write implied ENDFILE for REC=/POS= (PR #79637)
via flang-commits
flang-commits at lists.llvm.org
Fri Jan 26 11:12:58 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-runtime
Author: Peter Klausler (klausler)
<details>
<summary>Changes</summary>
An implied ENDFILE record, which truncates an external file, should be written to a sequential unit whenever the file is repositioned for a BACKSPACE or REWIND statement if a WRITE statement has executed since the last OPEN/BACKSPACE/REWIND.
But the REC= and POS= positioning specifiers don't apply to sequential units (they're for direct and stream units, resp.), so don't truncate the file when they're used.
---
Full diff: https://github.com/llvm/llvm-project/pull/79637.diff
1 Files Affected:
- (modified) flang/runtime/unit.cpp (+1-1)
``````````diff
diff --git a/flang/runtime/unit.cpp b/flang/runtime/unit.cpp
index 18590567c65eb0a..d927d012225672d 100644
--- a/flang/runtime/unit.cpp
+++ b/flang/runtime/unit.cpp
@@ -679,6 +679,7 @@ void ExternalFileUnit::Rewind(IoErrorHandler &handler) {
handler.SignalError(IostatRewindNonSequential,
"REWIND(UNIT=%d) on non-sequential file", unitNumber());
} else {
+ DoImpliedEndfile(handler);
SetPosition(0, handler);
currentRecordNumber = 1;
leftTabLimit.reset();
@@ -687,7 +688,6 @@ void ExternalFileUnit::Rewind(IoErrorHandler &handler) {
}
void ExternalFileUnit::SetPosition(std::int64_t pos, IoErrorHandler &handler) {
- DoImpliedEndfile(handler);
frameOffsetInFile_ = pos;
recordOffsetInFrame_ = 0;
if (access == Access::Direct) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/79637
More information about the flang-commits
mailing list