From 52ce5080eed47521bb61f93bbaceb6bfa0db074b Mon Sep 17 00:00:00 2001 From: Peter Klausler Date: Thu, 23 Jan 2025 15:02:48 -0800 Subject: [PATCH] [flang][runtime] Don't crash on ASYNCHRONOUS='NO' in child I/O 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 https://github.com/llvm/llvm-project/issues/124135. --- flang/runtime/io-api.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/flang/runtime/io-api.cpp b/flang/runtime/io-api.cpp index 7023f61ba34de..9dfa09ab332c2 100644 --- a/flang/runtime/io-api.cpp +++ b/flang/runtime/io-api.cpp @@ -770,18 +770,18 @@ bool IODEF(SetAsynchronous)( "SetAsynchronous() called after GetNewUnit() for an OPEN statement"); } open->unit().set_mayAsynchronous(isYes); + } else if (!isYes) { + // ASYNCHRONOUS='NO' is the default, so this is a no-op } else if (auto *ext{io.get_if()}) { - if (isYes) { - if (ext->unit().mayAsynchronous()) { - ext->SetAsynchronous(); - } else { - handler.SignalError(IostatBadAsynchronous); - } + if (ext->unit().mayAsynchronous()) { + ext->SetAsynchronous(); + } else { + handler.SignalError(IostatBadAsynchronous); } } else if (!io.get_if() && !io.get_if()) { - handler.Crash("SetAsynchronous() called when not in an OPEN or external " - "I/O statement"); + handler.Crash("SetAsynchronous('YES') called when not in an OPEN or " + "external I/O statement"); } return !handler.InError(); }