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
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;
}