[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 15:08:21 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG047884e71e67: [flang] runtime: catch OPEN(ACCESS='DIRECT',POSITION=) (authored by klausler).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

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

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.401007.patch
Type: text/x-patch
Size: 2204 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220118/6e8fc12a/attachment.bin>


More information about the flang-commits mailing list