[PATCH] D84079: [flang] Prevent bogus runtime I/O error message
Peter Klausler via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 17 17:03:50 PDT 2020
klausler created this revision.
klausler added reviewers: sscalpone, schweitz.
klausler added a project: Flang.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: DavidTruby.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The runtime was requiring that STATUS='OLD' be explicitly specified
on an OPEN statement for a connected unit. There error should issue
only if a STATUS= other than 'OLD' is specified; an OPEN with no
STATUS= specifier is okay.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D84079
Files:
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
@@ -302,7 +302,7 @@
private:
bool wasExtant_;
- OpenStatus status_{OpenStatus::Unknown};
+ std::optional<OpenStatus> status_;
Position position_{Position::AsIs};
std::optional<Action> action_;
OwningPtr<char> path_;
Index: flang/runtime/io-stmt.cpp
===================================================================
--- flang/runtime/io-stmt.cpp
+++ flang/runtime/io-stmt.cpp
@@ -162,11 +162,12 @@
}
int OpenStatementState::EndIoStatement() {
- if (wasExtant_ && status_ != OpenStatus::Old) {
- SignalError("OPEN statement for connected unit must have STATUS='OLD'");
+ if (wasExtant_ && status_ && *status_ != OpenStatus::Old) {
+ SignalError("OPEN statement for connected unit may not have STATUS= other "
+ "than 'OLD'");
}
- unit().OpenUnit(
- status_, action_, position_, std::move(path_), pathLength_, *this);
+ unit().OpenUnit(status_.value_or(OpenStatus::Unknown), action_, position_,
+ std::move(path_), pathLength_, *this);
return ExternalIoStatementBase::EndIoStatement();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84079.278937.patch
Type: text/x-patch
Size: 1207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200718/f9d35c70/attachment.bin>
More information about the llvm-commits
mailing list