Skip to content

Commit fee393e

Browse files
authored
[flang][runtime] Don't crash on ASYNCHRONOUS='NO' in child I/O (#124208)
When ASYNCHRONOUS='NO' appears in a data transfer statement control item list, don't crash if it isn't appropriate for the kind of I/O under way (such as child I/O). Fixes #124135.
1 parent 873426b commit fee393e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

flang/runtime/io-api.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -770,18 +770,18 @@ bool IODEF(SetAsynchronous)(
770770
"SetAsynchronous() called after GetNewUnit() for an OPEN statement");
771771
}
772772
open->unit().set_mayAsynchronous(isYes);
773+
} else if (!isYes) {
774+
// ASYNCHRONOUS='NO' is the default, so this is a no-op
773775
} else if (auto *ext{io.get_if<ExternalIoStatementBase>()}) {
774-
if (isYes) {
775-
if (ext->unit().mayAsynchronous()) {
776-
ext->SetAsynchronous();
777-
} else {
778-
handler.SignalError(IostatBadAsynchronous);
779-
}
776+
if (ext->unit().mayAsynchronous()) {
777+
ext->SetAsynchronous();
778+
} else {
779+
handler.SignalError(IostatBadAsynchronous);
780780
}
781781
} else if (!io.get_if<NoopStatementState>() &&
782782
!io.get_if<ErroneousIoStatementState>()) {
783-
handler.Crash("SetAsynchronous() called when not in an OPEN or external "
784-
"I/O statement");
783+
handler.Crash("SetAsynchronous('YES') called when not in an OPEN or "
784+
"external I/O statement");
785785
}
786786
return !handler.InError();
787787
}

0 commit comments

Comments
 (0)