diff --git a/flang/runtime/format-implementation.h b/flang/runtime/format-implementation.h --- a/flang/runtime/format-implementation.h +++ b/flang/runtime/format-implementation.h @@ -353,7 +353,7 @@ ++offset_; } } else if (edit.descriptor == 'D' && Capitalize(PeekNext()) == 'T') { - // DT'iotype'(v_list) user-defined derived type I/O + // DT['iotype'][(v_list)] user-defined derived type I/O edit.descriptor = DataEdit::DefinedDerivedType; ++offset_; if (auto quote{static_cast(PeekNext())}; diff --git a/flang/runtime/io-api.cpp b/flang/runtime/io-api.cpp --- a/flang/runtime/io-api.cpp +++ b/flang/runtime/io-api.cpp @@ -215,7 +215,7 @@ : "formatted input", false, DIR) ? &child->BeginIoStatement>( - *child, sourceFile, sourceLine) + *child, format, formatLength, sourceFile, sourceLine) : nullptr; } else { IoErrorHandler handler{terminator}; diff --git a/flang/runtime/io-error.cpp b/flang/runtime/io-error.cpp --- a/flang/runtime/io-error.cpp +++ b/flang/runtime/io-error.cpp @@ -59,10 +59,14 @@ void IoErrorHandler::Forward( int ioStatOrErrno, const char *msg, std::size_t length) { - SignalError(ioStatOrErrno); - if (ioStat_ != IostatOk && (flags_ & hasIoMsg)) { + if (ioStat_ != IostatOk && msg && (flags_ & hasIoMsg)) { ioMsg_ = SaveDefaultCharacter(msg, length, *this); } + if (ioStatOrErrno != IostatOk && msg) { + SignalError(ioStatOrErrno, "%.*s", static_cast(length), msg); + } else { + SignalError(ioStatOrErrno); + } } void IoErrorHandler::SignalErrno() { SignalError(errno); }