Commit e9d0f8ba authored by Peter Klausler's avatar Peter Klausler
Browse files

[flang] Don't drop format string for external child I/O

In user-defined derived type I/O to an external unit, don't
omit the format string from the constructor of ChildFormattedIoStatement.
And include any user IOMSG text in the crash message of the
parent, if it doesn't catch errors.

Differential Revision: https://reviews.llvm.org/D117903
parent 26fffc1b
...@@ -353,7 +353,7 @@ DataEdit FormatControl<CONTEXT>::GetNextDataEdit( ...@@ -353,7 +353,7 @@ DataEdit FormatControl<CONTEXT>::GetNextDataEdit(
++offset_; ++offset_;
} }
} else if (edit.descriptor == 'D' && Capitalize(PeekNext()) == 'T') { } 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; edit.descriptor = DataEdit::DefinedDerivedType;
++offset_; ++offset_;
if (auto quote{static_cast<char>(PeekNext())}; if (auto quote{static_cast<char>(PeekNext())};
......
...@@ -215,7 +215,7 @@ Cookie BeginExternalFormattedIO(const char *format, std::size_t formatLength, ...@@ -215,7 +215,7 @@ Cookie BeginExternalFormattedIO(const char *format, std::size_t formatLength,
: "formatted input", : "formatted input",
false, DIR) false, DIR)
? &child->BeginIoStatement<ChildFormattedIoStatementState<DIR>>( ? &child->BeginIoStatement<ChildFormattedIoStatementState<DIR>>(
*child, sourceFile, sourceLine) *child, format, formatLength, sourceFile, sourceLine)
: nullptr; : nullptr;
} else { } else {
IoErrorHandler handler{terminator}; IoErrorHandler handler{terminator};
......
...@@ -59,10 +59,14 @@ void IoErrorHandler::SignalError(int iostatOrErrno) { ...@@ -59,10 +59,14 @@ void IoErrorHandler::SignalError(int iostatOrErrno) {
void IoErrorHandler::Forward( void IoErrorHandler::Forward(
int ioStatOrErrno, const char *msg, std::size_t length) { int ioStatOrErrno, const char *msg, std::size_t length) {
SignalError(ioStatOrErrno); if (ioStat_ != IostatOk && msg && (flags_ & hasIoMsg)) {
if (ioStat_ != IostatOk && (flags_ & hasIoMsg)) {
ioMsg_ = SaveDefaultCharacter(msg, length, *this); ioMsg_ = SaveDefaultCharacter(msg, length, *this);
} }
if (ioStatOrErrno != IostatOk && msg) {
SignalError(ioStatOrErrno, "%.*s", static_cast<int>(length), msg);
} else {
SignalError(ioStatOrErrno);
}
} }
void IoErrorHandler::SignalErrno() { SignalError(errno); } void IoErrorHandler::SignalErrno() { SignalError(errno); }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment