Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions flang-rt/include/flang-rt/runtime/io-stmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -730,8 +730,7 @@ class ChildListIoStatementState : public ChildIoStatementState<DIR>,
RT_API_ATTRS bool AdvanceRecord(int = 1);
RT_API_ATTRS int EndIoStatement();
RT_API_ATTRS bool CanAdvance() {
return DIR == Direction::Input &&
(canAdvance_ || this->mutableModes().inNamelist);
return canAdvance_ || this->mutableModes().inNamelist;
}

private:
Expand Down
7 changes: 4 additions & 3 deletions flang-rt/lib/runtime/edit-output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,10 @@ bool RT_API_ATTRS EditIntegerOutput(IoStatementState &io, const DataEdit &edit,
}
if (edit.IsListDirected()) {
int total{std::max(leadingSpaces, 1) + subTotal};
if (io.GetConnectionState().NeedAdvance(static_cast<std::size_t>(total)) &&
!io.AdvanceRecord()) {
return false;
if (io.GetConnectionState().NeedAdvance(static_cast<std::size_t>(total))) {
if (!io.AdvanceRecord()) {
return false;
}
}
leadingSpaces = 1;
} else if (!edit.width) {
Expand Down
28 changes: 14 additions & 14 deletions flang-rt/lib/runtime/io-stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1109,20 +1109,20 @@ ChildListIoStatementState<DIR>::ChildListIoStatementState(
ChildIo &child, const char *sourceFile, int sourceLine)
: ChildIoStatementState<DIR>{child, sourceFile, sourceLine} {
#if !defined(RT_DEVICE_AVOID_RECURSION)
if constexpr (DIR == Direction::Input) {
if (const auto *listInput{child.parent()
.get_if<ListDirectedStatementState<Direction::Input>>()}) {
this->set_eatComma(listInput->eatComma());
this->namelistGroup_ = listInput->namelistGroup();
if (auto *childListInput{child.parent()
.get_if<ChildListIoStatementState<Direction::Input>>()}) {
// Child list input whose parent is child list input: can advance
// if the parent can.
this->canAdvance_ = childListInput->CanAdvance();
} else {
// Child list input of top-level list input: can advance.
this->canAdvance_ = true;
}
if (const auto *listParent{
child.parent().get_if<ListDirectedStatementState<DIR>>()}) {
if constexpr (DIR == Direction::Input) {
this->set_eatComma(listParent->eatComma());
this->namelistGroup_ = listParent->namelistGroup();
}
if (auto *childListParent{
child.parent().get_if<ChildListIoStatementState<DIR>>()}) {
// Child list I/O whose parent is child list I/O: can advance
// if the parent can.
this->canAdvance_ = childListParent->CanAdvance();
} else {
// Child list I/O of top-level list I/O: can advance.
this->canAdvance_ = true;
}
}
#else
Expand Down
Loading