[flang-commits] [flang] f6253eb - [flang][runtime] Fix INQUIRE(POS=n) for non-advancing I/O
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Wed Jun 15 14:17:31 PDT 2022
Author: Peter Klausler
Date: 2022-06-15T14:14:06-07:00
New Revision: f6253eb9ba3838922c1b4750f8b3dcb7c30ffd38
URL: https://github.com/llvm/llvm-project/commit/f6253eb9ba3838922c1b4750f8b3dcb7c30ffd38
DIFF: https://github.com/llvm/llvm-project/commit/f6253eb9ba3838922c1b4750f8b3dcb7c30ffd38.diff
LOG: [flang][runtime] Fix INQUIRE(POS=n) for non-advancing I/O
Position inquiries need to account for offsets in records to be
accurate in the case of non-advancing I/O.
Differential Revision: https://reviews.llvm.org/D127789
Added:
Modified:
flang/runtime/unit.h
Removed:
################################################################################
diff --git a/flang/runtime/unit.h b/flang/runtime/unit.h
index dca5e297b254..3498a5e9682f 100644
--- a/flang/runtime/unit.h
+++ b/flang/runtime/unit.h
@@ -96,7 +96,7 @@ class ExternalFileUnit : public ConnectionState,
void SetPosition(std::int64_t, IoErrorHandler &); // zero-based
std::int64_t InquirePos() const {
// 12.6.2.11 defines POS=1 as the beginning of file
- return frameOffsetInFile_ + 1;
+ return frameOffsetInFile_ + recordOffsetInFrame_ + positionInRecord + 1;
}
ChildIo *GetChildIo() { return child_.get(); }
More information about the flang-commits
mailing list