[flang-commits] [PATCH] D117596: [flang] runtime: catch OPEN(ACCESS='DIRECT', POSITION=)
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Tue Jan 18 12:26:20 PST 2022
klausler created this revision.
klausler added a reviewer: vdonaldson.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
klausler requested review of this revision.
A POSITION= specifier may not be used on a direct access file.
https://reviews.llvm.org/D117596
Files:
flang/runtime/io-api.cpp
flang/runtime/io-stmt.cpp
flang/runtime/io-stmt.h
Index: flang/runtime/io-stmt.h
===================================================================
--- flang/runtime/io-stmt.h
+++ flang/runtime/io-stmt.h
@@ -577,7 +577,7 @@
private:
bool wasExtant_;
std::optional<OpenStatus> status_;
- Position position_{Position::AsIs};
+ std::optional<Position> position_;
std::optional<Action> action_;
Convert convert_{Convert::Native};
OwningPtr<char> path_;
Index: flang/runtime/io-stmt.cpp
===================================================================
--- flang/runtime/io-stmt.cpp
+++ flang/runtime/io-stmt.cpp
@@ -208,20 +208,30 @@
}
int OpenStatementState::EndIoStatement() {
+ if (position_) {
+ if (access_ && *access_ == Access::Direct) {
+ SignalError("POSITION= may not be set with ACCESS='DIRECT'");
+ position_.reset();
+ }
+ }
if (path_.get() || wasExtant_ ||
(status_ && *status_ == OpenStatus::Scratch)) {
- unit().OpenUnit(status_, action_, position_, std::move(path_), pathLength_,
- convert_, *this);
+ unit().OpenUnit(status_, action_, position_.value_or(Position::AsIs),
+ std::move(path_), pathLength_, convert_, *this);
} else {
- unit().OpenAnonymousUnit(status_, action_, position_, convert_, *this);
+ unit().OpenAnonymousUnit(
+ status_, action_, position_.value_or(Position::AsIs), convert_, *this);
}
if (access_) {
if (*access_ != unit().access) {
if (wasExtant_) {
SignalError("ACCESS= may not be changed on an open unit");
+ access_.reset();
}
}
- unit().access = *access_;
+ if (access_) {
+ unit().access = *access_;
+ }
}
if (!unit().isUnformatted) {
unit().isUnformatted = isUnformatted_;
Index: flang/runtime/io-api.cpp
===================================================================
--- flang/runtime/io-api.cpp
+++ flang/runtime/io-api.cpp
@@ -519,7 +519,7 @@
ConnectionState &connection{io.GetConnectionState()};
if (connection.access != Access::Stream) {
io.GetIoErrorHandler().SignalError(
- "REC= may not appear unless ACCESS='STREAM'");
+ "POS= may not appear unless ACCESS='STREAM'");
return false;
}
if (pos < 1) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117596.400949.patch
Type: text/x-patch
Size: 2204 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220118/ac6f9772/attachment-0001.bin>
More information about the flang-commits
mailing list