[flang-commits] [flang] b0a971d - [flang] Prevent bogus runtime I/O error message
peter klausler via flang-commits
flang-commits at lists.llvm.org
Fri Jul 17 17:23:41 PDT 2020
Author: peter klausler
Date: 2020-07-17T17:21:54-07:00
New Revision: b0a971d25cdc9fdb7ca1a21db1d0fd409f58f85a
URL: https://github.com/llvm/llvm-project/commit/b0a971d25cdc9fdb7ca1a21db1d0fd409f58f85a
DIFF: https://github.com/llvm/llvm-project/commit/b0a971d25cdc9fdb7ca1a21db1d0fd409f58f85a.diff
LOG: [flang] Prevent bogus runtime I/O error message
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.
Reviewed By: sscalpone
Differential Revision: https://reviews.llvm.org/D84079
Added:
Modified:
flang/runtime/io-stmt.cpp
flang/runtime/io-stmt.h
Removed:
################################################################################
diff --git a/flang/runtime/io-stmt.cpp b/flang/runtime/io-stmt.cpp
index 8efda2d09a77..9e89e0c28816 100644
--- a/flang/runtime/io-stmt.cpp
+++ b/flang/runtime/io-stmt.cpp
@@ -162,11 +162,12 @@ void OpenStatementState::set_path(
}
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();
}
diff --git a/flang/runtime/io-stmt.h b/flang/runtime/io-stmt.h
index 6f5ca2c48112..da58769ef114 100644
--- a/flang/runtime/io-stmt.h
+++ b/flang/runtime/io-stmt.h
@@ -302,7 +302,7 @@ class OpenStatementState : public ExternalIoStatementBase {
private:
bool wasExtant_;
- OpenStatus status_{OpenStatus::Unknown};
+ std::optional<OpenStatus> status_;
Position position_{Position::AsIs};
std::optional<Action> action_;
OwningPtr<char> path_;
More information about the flang-commits
mailing list