From fde42ac5b9d467debd37a57dc941734678cc18c3 Mon Sep 17 00:00:00 2001 From: Peter Klausler Date: Sun, 14 Aug 2022 10:49:19 -0700 Subject: [PATCH] [flang][runtime] Don't raise internal error in user error recovery situation In the case of a data transfer I/O statement with an illegal unit number and error recovery, ensure that data transfer API calls don't raise internal errors due to the I/O statement representation unexpectedly being something other than a data transfer statement. Differential Revision: https://reviews.llvm.org/D132160 --- flang/runtime/io-stmt.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flang/runtime/io-stmt.h b/flang/runtime/io-stmt.h index 0482a13..46fc215 100644 --- a/flang/runtime/io-stmt.h +++ b/flang/runtime/io-stmt.h @@ -189,10 +189,10 @@ public: if (get_if>()) { return true; } else { - if (!get_if()) { - GetIoErrorHandler().Crash( - "%s called for I/O statement that is not formatted %s", name, - D == Direction::Output ? "output" : "input"); + auto &handler{GetIoErrorHandler()}; + if (!handler.InError()) { + handler.Crash("%s called for I/O statement that is not formatted %s", + name, D == Direction::Output ? "output" : "input"); } return false; } -- 2.7.4