Skip to content

Commit ae46b9e

Browse files
authored
[flang][runtime] Fix bug with NAMELIST in child input (#159173)
Don't let "hitSlash_" flag in child input propagate back to the parent input statement's state when the child input was NAMELIST and the NAMELIST input has properly consumed the terminal '/' character. (It can get set if NAMELIST item input ran into it.) The current failure to reset that flag is causing list-directed parent input to stop early. Fixes llvm/llvm-project#159127.
1 parent 59c77e7 commit ae46b9e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

flang-rt/lib/runtime/namelist.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,12 @@ bool IODEF(InputNamelist)(Cookie cookie, const NamelistGroup &group) {
624624
}
625625
if (next && *next == '/') {
626626
io.HandleRelativePosition(byteCount);
627+
if (auto *listInput{
628+
io.get_if<ListDirectedStatementState<Direction::Input>>()}) {
629+
// Don't let the namelist's terminal '/' mess up a parent I/O's
630+
// list-directed input.
631+
listInput->set_hitSlash(false);
632+
}
627633
} else if (*next && (*next == '&' || *next == '$')) {
628634
// stop at beginning of next group
629635
} else {

0 commit comments

Comments
 (0)