[flang] runtime error on inappropriate OPEN(UNIT=extant,RECL=n)

Don't let a program set a fixed RECL= on a connected unit unless
it already had one with the same value.

Differential Revision: https://reviews.llvm.org/D117595
This commit is contained in:
Peter Klausler 2022-01-10 12:04:30 -08:00
parent 17beee44e1
commit e847b30369
1 changed files with 7 additions and 5 deletions

View File

@ -826,13 +826,15 @@ bool IONAME(SetRecl)(Cookie cookie, std::size_t n) {
}
if (n <= 0) {
io.GetIoErrorHandler().SignalError("RECL= must be greater than zero");
}
if (open->wasExtant() &&
open->unit().openRecl.value_or(n) != static_cast<std::int64_t>(n)) {
return false;
} else if (open->wasExtant() &&
open->unit().openRecl.value_or(0) != static_cast<std::int64_t>(n)) {
open->SignalError("RECL= may not be changed for an open unit");
return false;
} else {
open->unit().openRecl = n;
return true;
}
open->unit().openRecl = n;
return true;
}
bool IONAME(SetStatus)(Cookie cookie, const char *keyword, std::size_t length) {