[flang-commits] [PATCH] D122509: [flang] Catch bad OPEN(STATUS=) cases
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Fri Mar 25 15:10:04 PDT 2022
klausler created this revision.
klausler added a reviewer: vdonaldson.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.
STATUS='NEW' and 'REPLACE' require FILE= to be present.
STATUS='SCRATCH' may not appear with FILE=.
These errors are caught at compilation time when constant character
strings are used in an OPEN statement, but the runtime needs
to enforce them as well to catch errors in OPEN statements
with character variables and expressions.
https://reviews.llvm.org/D122509
Files:
flang/runtime/io-stmt.cpp
Index: flang/runtime/io-stmt.cpp
===================================================================
--- flang/runtime/io-stmt.cpp
+++ flang/runtime/io-stmt.cpp
@@ -232,6 +232,14 @@
position_.reset();
}
}
+ if (status_) { // 12.5.6.10
+ if ((*status_ == OpenStatus::New || *status_ == OpenStatus::Replace) &&
+ !path_.get()) {
+ SignalError("FILE= required on OPEN with STATUS='NEW' or 'REPLACE'");
+ } else if (*status_ == OpenStatus::Scratch && path_.get()) {
+ SignalError("FILE= may not appear on OPEN with STATUS='SCRATCH'");
+ }
+ }
if (path_.get() || wasExtant_ ||
(status_ && *status_ == OpenStatus::Scratch)) {
unit().OpenUnit(status_, action_, position_.value_or(Position::AsIs),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122509.418336.patch
Type: text/x-patch
Size: 748 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220325/04c00a84/attachment.bin>
More information about the flang-commits
mailing list