[flang-commits] [PATCH] D117903: [flang] Don't drop format string for external child I/O
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Fri Jan 21 09:23:27 PST 2022
klausler created this revision.
klausler added a reviewer: PeteSteinfeld.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
klausler requested review of this revision.
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.
https://reviews.llvm.org/D117903
Files:
flang/runtime/format-implementation.h
flang/runtime/io-api.cpp
flang/runtime/io-error.cpp
Index: flang/runtime/io-error.cpp
===================================================================
--- flang/runtime/io-error.cpp
+++ 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<int>(length), msg);
+ } else {
+ SignalError(ioStatOrErrno);
+ }
}
void IoErrorHandler::SignalErrno() { SignalError(errno); }
Index: flang/runtime/io-api.cpp
===================================================================
--- flang/runtime/io-api.cpp
+++ flang/runtime/io-api.cpp
@@ -208,7 +208,7 @@
: "formatted input",
false, DIR)
? &child->BeginIoStatement<ChildFormattedIoStatementState<DIR>>(
- *child, sourceFile, sourceLine)
+ *child, format, formatLength, sourceFile, sourceLine)
: nullptr;
} else {
if (!unit.isUnformatted.has_value()) {
Index: flang/runtime/format-implementation.h
===================================================================
--- flang/runtime/format-implementation.h
+++ flang/runtime/format-implementation.h
@@ -386,7 +386,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<char>(PeekNext())};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117903.402015.patch
Type: text/x-patch
Size: 1803 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220121/448ad522/attachment.bin>
More information about the flang-commits
mailing list