[flang-commits] [flang] fee393e - [flang][runtime] Don't crash on ASYNCHRONOUS='NO' in child I/O (#124208)
via flang-commits
flang-commits at lists.llvm.org
Mon Jan 27 08:59:19 PST 2025
Author: Peter Klausler
Date: 2025-01-27T08:59:15-08:00
New Revision: fee393e4ea2b53139ee7924e3aa818433d70cfc7
URL: https://github.com/llvm/llvm-project/commit/fee393e4ea2b53139ee7924e3aa818433d70cfc7
DIFF: https://github.com/llvm/llvm-project/commit/fee393e4ea2b53139ee7924e3aa818433d70cfc7.diff
LOG: [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 https://github.com/llvm/llvm-project/issues/124135.
Added:
Modified:
flang/runtime/io-api.cpp
Removed:
################################################################################
diff --git a/flang/runtime/io-api.cpp b/flang/runtime/io-api.cpp
index 7023f61ba34de7..9dfa09ab332c2a 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<ExternalIoStatementBase>()}) {
- 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<NoopStatementState>() &&
!io.get_if<ErroneousIoStatementState>()) {
- 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();
}
More information about the flang-commits
mailing list