[flang] [llvm] [flang][runtime] Handle null list-directed fields in child input (PR #155707)
Peter Klausler via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 28 10:49:30 PDT 2025
https://github.com/klausler updated https://github.com/llvm/llvm-project/pull/155707
>From 96ce83053d3d95f6e375c615e9cb1b911d2134be Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Wed, 27 Aug 2025 15:08:57 -0700
Subject: [PATCH] [flang][runtime] Handle null list-directed fields in child
input
When a "null" list-directed input field is encountered for a
corresponding effective input item, leave it unmodified even
if it has a derived type with a READ(FORMATTED) defined input
subroutine.
Fixes https://github.com/llvm/llvm-project/issues/154791, although
not with the result that was intended.
---
flang-rt/lib/runtime/descriptor-io.cpp | 2 ++
flang/docs/Extensions.md | 7 +++++++
2 files changed, 9 insertions(+)
diff --git a/flang-rt/lib/runtime/descriptor-io.cpp b/flang-rt/lib/runtime/descriptor-io.cpp
index a60d0b90da467..668190febf397 100644
--- a/flang-rt/lib/runtime/descriptor-io.cpp
+++ b/flang-rt/lib/runtime/descriptor-io.cpp
@@ -170,6 +170,8 @@ static RT_API_ATTRS Fortran::common::optional<bool> DefinedFormattedIo(
io.GotChar(io.InquirePos() - *startPos);
}
return handler.GetIoStat() == IostatOk;
+ } else if (peek && peek->descriptor == DataEdit::ListDirectedNullValue) {
+ return false;
} else {
// There's a defined I/O subroutine, but there's a FORMAT present and
// it does not have a DT data edit descriptor, so apply default formatting
diff --git a/flang/docs/Extensions.md b/flang/docs/Extensions.md
index b20503e542fb8..cf528b8231d56 100644
--- a/flang/docs/Extensions.md
+++ b/flang/docs/Extensions.md
@@ -910,6 +910,13 @@ print *, [(j,j=1,10)]
`ALLOCATE` and `DEALLOCATE` statements with error recovery for
multiple variables.
+* When a "null" value is encountered in list-directed input, the
+ corresponding effective item in the data list is left unchanged,
+ even when it has a derived type with a defined `READ(FORMATTED)`
+ subroutine. This is the most literal reading of F'2023 13.10.3.2p2
+ and the portable interpretation across the most common Fortran
+ compilers.
+
## De Facto Standard Features
* `EXTENDS_TYPE_OF()` returns `.TRUE.` if both of its arguments have the
More information about the llvm-commits
mailing list