[flang-commits] [PATCH] D84079: [flang] Prevent bogus runtime I/O error message

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Jul 17 17:23:48 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGb0a971d25cdc: [flang] Prevent bogus runtime I/O error message (authored by klausler).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84079/new/

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.278943.patch
Type: text/x-patch
Size: 1207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20200718/7a0c6638/attachment-0001.bin>


More information about the flang-commits mailing list