[flang-commits] [flang] [flang][runtime] Don't crash on ASYNCHRONOUS='NO' in child I/O (PR #124208)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Thu Jan 23 15:22:21 PST 2025
https://github.com/klausler created https://github.com/llvm/llvm-project/pull/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.
>From 52ce5080eed47521bb61f93bbaceb6bfa0db074b Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
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 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