[llvm] [flang][runtime] Handle empty NAMELIST value list (PR #151770)

Peter Klausler via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 4 11:41:15 PDT 2025


https://github.com/klausler updated https://github.com/llvm/llvm-project/pull/151770

>From 64a3811b9161bff60de7c3fb3262914587f21d28 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Fri, 1 Aug 2025 13:40:18 -0700
Subject: [PATCH] [flang][runtime] Handle empty NAMELIST value list

InputNamelist() returns early if any value list read in by
InputDerivedType() or DescriptorIo<Input>() is empty, since
they return false.  But an empty value list is okay, and the
early return should occur only on error.

Fixes https://github.com/llvm/llvm-project/issues/151756.
---
 flang-rt/lib/runtime/namelist.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/flang-rt/lib/runtime/namelist.cpp b/flang-rt/lib/runtime/namelist.cpp
index 2325ca18ba7aa..828215e885e97 100644
--- a/flang-rt/lib/runtime/namelist.cpp
+++ b/flang-rt/lib/runtime/namelist.cpp
@@ -570,12 +570,14 @@ bool IODEF(InputNamelist)(Cookie cookie, const NamelistGroup &group) {
         addendum && addendum->derivedType()) {
       const NonTbpDefinedIoTable *table{group.nonTbpDefinedIo};
       listInput->ResetForNextNamelistItem(/*inNamelistSequence=*/true);
-      if (!IONAME(InputDerivedType)(cookie, *useDescriptor, table)) {
+      if (!IONAME(InputDerivedType)(cookie, *useDescriptor, table) &&
+          handler.InError()) {
         return false;
       }
     } else {
       listInput->ResetForNextNamelistItem(useDescriptor->rank() > 0);
-      if (!descr::DescriptorIO<Direction::Input>(io, *useDescriptor)) {
+      if (!descr::DescriptorIO<Direction::Input>(io, *useDescriptor) &&
+          handler.InError()) {
         return false;
       }
     }



More information about the llvm-commits mailing list