[flang-commits] [flang] e847b30 - [flang] runtime error on inappropriate OPEN(UNIT=extant, RECL=n)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Tue Jan 18 14:54:35 PST 2022
Author: Peter Klausler
Date: 2022-01-18T14:54:27-08:00
New Revision: e847b30369adffd5e90401918eb9efbd82b28607
URL: https://github.com/llvm/llvm-project/commit/e847b30369adffd5e90401918eb9efbd82b28607
DIFF: https://github.com/llvm/llvm-project/commit/e847b30369adffd5e90401918eb9efbd82b28607.diff
LOG: [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
Added:
Modified:
flang/runtime/io-api.cpp
Removed:
################################################################################
diff --git a/flang/runtime/io-api.cpp b/flang/runtime/io-api.cpp
index 213fd5ddeca7..88a5c3b6b584 100644
--- a/flang/runtime/io-api.cpp
+++ b/flang/runtime/io-api.cpp
@@ -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) {
More information about the flang-commits
mailing list