Skip to content

[flang][runtime] Crash more informatively in defined I/O error case #74134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions flang/include/flang/Runtime/iostat.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ enum Iostat {
IostatBadOpOnChildUnit,
IostatBadNewUnit,
IostatBadListDirectedInputSeparator,
IostatNonExternalDefinedUnformattedIo,
};

const char *IostatErrorString(int);
Expand Down
5 changes: 4 additions & 1 deletion flang/runtime/descriptor-io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ bool DefinedUnformattedIo(IoStatementState &io, const Descriptor &descriptor,
// Unformatted I/O must have an external unit (or child thereof).
IoErrorHandler &handler{io.GetIoErrorHandler()};
ExternalFileUnit *external{io.GetExternalFileUnit()};
RUNTIME_CHECK(handler, external != nullptr);
if (!external) { // INQUIRE(IOLENGTH=)
handler.SignalError(IostatNonExternalDefinedUnformattedIo);
return false;
}
ChildIo &child{external->PushChildIo(io)};
int unit{external->unitNumber()};
int ioStat{IostatOk};
Expand Down
2 changes: 2 additions & 0 deletions flang/runtime/iostat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ const char *IostatErrorString(int iostat) {
return "NEWUNIT= without FILE= or STATUS='SCRATCH'";
case IostatBadListDirectedInputSeparator:
return "List-directed input value has trailing unused characters";
case IostatNonExternalDefinedUnformattedIo:
return "Defined unformatted I/O without an external unit";
default:
return nullptr;
}
Expand Down