[flang-commits] [PATCH] D106694: [flang] Runtime: Reset list-directed input state for each NAMELIST item

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Jul 23 18:21:54 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe093cbb7ae14: [flang] Runtime: Reset list-directed input state for each NAMELIST item (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/D106694/new/

https://reviews.llvm.org/D106694

Files:
  flang/runtime/io-stmt.h
  flang/runtime/namelist.cpp


Index: flang/runtime/namelist.cpp
===================================================================
--- flang/runtime/namelist.cpp
+++ flang/runtime/namelist.cpp
@@ -260,6 +260,8 @@
   ConnectionState &connection{io.GetConnectionState()};
   connection.modes.inNamelist = true;
   IoErrorHandler &handler{io.GetIoErrorHandler()};
+  auto *listInput{io.get_if<ListDirectedStatementState<Direction::Input>>()};
+  RUNTIME_CHECK(handler, listInput != nullptr);
   // Check the group header
   std::optional<char32_t> next{io.GetNextNonBlank()};
   if (!next || *next != '&') {
@@ -331,6 +333,7 @@
     }
     io.HandleRelativePosition(1);
     // Read the values into the descriptor
+    listInput->ResetForNextNamelistItem();
     if (!descr::DescriptorIO<Direction::Input>(io, *useDescriptor)) {
       return false;
     }
Index: flang/runtime/io-stmt.h
===================================================================
--- flang/runtime/io-stmt.h
+++ flang/runtime/io-stmt.h
@@ -217,6 +217,16 @@
   std::optional<DataEdit> GetNextDataEdit(
       IoStatementState &, int maxRepeat = 1);
 
+  // Each NAMELIST input item is a distinct "list-directed"
+  // input statement.  This member function resets this state
+  // so that repetition and null values work correctly for each
+  // successive NAMELIST input item.
+  void ResetForNextNamelistItem() {
+    remaining_ = 0;
+    isFirstItem_ = true;
+    realPart_ = imaginaryPart_ = false;
+  }
+
 private:
   int remaining_{0}; // for "r*" repetition
   std::int64_t initialRecordNumber_;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106694.361397.patch
Type: text/x-patch
Size: 1546 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20210724/e9643ded/attachment.bin>


More information about the flang-commits mailing list