Skip to content

Commit 9005ae5

Browse files
authored
[flang][runtime] Handle null list-directed fields in child input (#155707)
List-directed input statements maintain two flags ("eatComma_" and "hitSlash_") in their state that allow GetNextDataEdit() to detect and handle field separators (usually ',') and slashes in the input stream. For list-directed input in a defined input subroutine, it's necessary to copy those flags from the parent list-directed input statement (if any) and update them afterwards. Fixes #154791.
1 parent b1e1090 commit 9005ae5

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

flang-rt/lib/runtime/descriptor-io.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ static RT_API_ATTRS Fortran::common::optional<bool> DefinedFormattedIo(
170170
io.GotChar(io.InquirePos() - *startPos);
171171
}
172172
return handler.GetIoStat() == IostatOk;
173+
} else if (peek && peek->descriptor == DataEdit::ListDirectedNullValue) {
174+
return false;
173175
} else {
174176
// There's a defined I/O subroutine, but there's a FORMAT present and
175177
// it does not have a DT data edit descriptor, so apply default formatting

flang/docs/Extensions.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,13 @@ print *, [(j,j=1,10)]
910910
`ALLOCATE` and `DEALLOCATE` statements with error recovery for
911911
multiple variables.
912912

913+
* When a "null" value is encountered in list-directed input, the
914+
corresponding effective item in the data list is left unchanged,
915+
even when it has a derived type with a defined `READ(FORMATTED)`
916+
subroutine. This is the most literal reading of F'2023 13.10.3.2p2
917+
and the portable interpretation across the most common Fortran
918+
compilers.
919+
913920
## De Facto Standard Features
914921

915922
* `EXTENDS_TYPE_OF()` returns `.TRUE.` if both of its arguments have the

0 commit comments

Comments
 (0)