[flang][runtime] Don't emit empty lines for bad writes

When an error occurs in a formatted sequential output statement
and no output was ever emitted, don't emit a blank record.
This matches the error case behavior of other Fortran compilers.

Differential Revision: https://reviews.llvm.org/D123734
This commit is contained in:
Peter Klausler 2022-04-12 15:15:46 -07:00
parent 7fde4e2213
commit 1fe7a187ae

View file

@ -527,6 +527,11 @@ bool ExternalFileUnit::AdvanceRecord(IoErrorHandler &handler) {
} else {
// Unformatted stream: nothing to do
}
} else if (handler.GetIoStat() != IostatOk &&
furthestPositionInRecord == 0) {
// Error in formatted variable length record, and no output yet; do
// nothing, like most other Fortran compilers do.
return true;
} else {
// Terminate formatted variable length record
const char *lineEnding{"\n"};