[flang][runtime] Respect PAD='NO' on READ/WRITE

The check for the PAD= setting should examine the mutable modes
of the current I/O statement, not the persistent modes of the
I/O unit.

Differential Revision: https://reviews.llvm.org/D128389
This commit is contained in:
Peter Klausler 2022-06-17 11:45:14 -07:00
parent bc07634b5a
commit 1650fb8a53
1 changed files with 4 additions and 3 deletions

View File

@ -677,7 +677,8 @@ bool IoStatementState::CheckForEndOfRecord() {
if (auto length{connection.EffectiveRecordLength()}) {
if (connection.positionInRecord >= *length) {
IoErrorHandler &handler{GetIoErrorHandler()};
if (mutableModes().nonAdvancing) {
const auto &modes{mutableModes()};
if (modes.nonAdvancing) {
if (connection.access == Access::Stream &&
connection.unterminatedRecord) {
// Reading final unterminated record left by a
@ -687,10 +688,10 @@ bool IoStatementState::CheckForEndOfRecord() {
} else {
handler.SignalEor();
}
} else if (!connection.modes.pad) {
} else if (!modes.pad) {
handler.SignalError(IostatRecordReadOverrun);
}
return connection.modes.pad; // PAD='YES'
return modes.pad; // PAD='YES'
}
}
}