[flang-commits] [PATCH] D132157: [flang][runtime] Catch input error on missing NAMELIST scalar

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Aug 18 14:37:20 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG2c39975d99df: [flang][runtime] Catch input error on missing NAMELIST scalar (authored by klausler).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132157

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


Index: flang/runtime/namelist.cpp
===================================================================
--- flang/runtime/namelist.cpp
+++ flang/runtime/namelist.cpp
@@ -475,7 +475,7 @@
     }
     io.HandleRelativePosition(byteCount);
     // Read the values into the descriptor.  An array can be short.
-    listInput->ResetForNextNamelistItem();
+    listInput->ResetForNextNamelistItem(useDescriptor->rank() > 0);
     if (!descr::DescriptorIO<Direction::Input>(io, *useDescriptor)) {
       return false;
     }
@@ -494,8 +494,9 @@
 }
 
 bool IsNamelistName(IoStatementState &io) {
-  if (io.get_if<ListDirectedStatementState<Direction::Input>>()) {
-    if (io.mutableModes().inNamelist) {
+  if (auto *listInput{
+          io.get_if<ListDirectedStatementState<Direction::Input>>()}) {
+    if (listInput->inNamelistArray()) {
       SavedPosition savedPosition{io};
       std::size_t byteCount{0};
       if (auto ch{io.GetNextNonBlank(byteCount)}) {
Index: flang/runtime/io-stmt.h
===================================================================
--- flang/runtime/io-stmt.h
+++ flang/runtime/io-stmt.h
@@ -293,6 +293,9 @@
 class ListDirectedStatementState<Direction::Input>
     : public FormattedIoStatementState<Direction::Input> {
 public:
+  bool inNamelistArray() const { return inNamelistArray_; }
+  void set_inNamelistArray(bool yes = true) { inNamelistArray_ = yes; }
+
   // Skips value separators, handles repetition and null values.
   // Vacant when '/' appears; present with descriptor == ListDirectedNullValue
   // when a null value appears.
@@ -303,10 +306,11 @@
   // input statement.  This member function resets some state so that
   // repetition and null values work correctly for each successive
   // NAMELIST input item.
-  void ResetForNextNamelistItem() {
+  void ResetForNextNamelistItem(bool inNamelistArray) {
     remaining_ = 0;
     eatComma_ = false;
     realPart_ = imaginaryPart_ = false;
+    inNamelistArray_ = inNamelistArray;
   }
 
 private:
@@ -316,6 +320,7 @@
   bool hitSlash_{false}; // once '/' is seen, nullify further items
   bool realPart_{false};
   bool imaginaryPart_{false};
+  bool inNamelistArray_{false};
 };
 
 template <Direction DIR>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132157.453791.patch
Type: text/x-patch
Size: 2206 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220818/3c2ce2dd/attachment.bin>


More information about the flang-commits mailing list