[flang][runtime] Don't raise internal error in user error recovery situation
authorPeter Klausler <pklausler@nvidia.com>
Sun, 14 Aug 2022 17:49:19 +0000 (10:49 -0700)
committerPeter Klausler <pklausler@nvidia.com>
Thu, 18 Aug 2022 21:51:04 +0000 (14:51 -0700)
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

index 0482a13..46fc215 100644 (file)
@@ -189,10 +189,10 @@ public:
     if (get_if<FormattedIoStatementState<D>>()) {
       return true;
     } else {
-      if (!get_if<ErroneousIoStatementState>()) {
-        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;
     }