[flang-commits] [PATCH] D108990: [flang] Set default form if unspecified at end of OPEN statement
Jean Perier via Phabricator via flang-commits
flang-commits at lists.llvm.org
Tue Aug 31 05:29:50 PDT 2021
jeanPerier created this revision.
jeanPerier added reviewers: klausler, PeteSteinfeld.
jeanPerier added a project: Flang.
Herald added a subscriber: jdoerfert.
jeanPerier requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The standard specifies that the form must be set to a default at the
end of an open statement (C.7.4 point 2) where it was not specified.
Only in the case of a pre-connected unit can the form be deferred
until the first data transfer statement.
Set back the default form setting in OpenStatementState::EndIoStatement
that had been removed when deferring the pre-connected unit from setting
in 199a623ebf808a01e920ebd9904c99e633c33a1f <https://reviews.llvm.org/rG199a623ebf808a01e920ebd9904c99e633c33a1f>.
Also return "UNDEFINED" instead of "UNKNOWN" to the FORM inquiry when the
form was not yet specified as defined in 12.10.2.12.
Related test: syntax 215a216.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D108990
Files:
flang/runtime/io-stmt.cpp
Index: flang/runtime/io-stmt.cpp
===================================================================
--- flang/runtime/io-stmt.cpp
+++ flang/runtime/io-stmt.cpp
@@ -243,6 +243,10 @@
}
unit().isUnformatted = *isUnformatted_;
}
+ if (!unit().isUnformatted) {
+ // Set default format (C.7.4 point 2).
+ unit().isUnformatted = unit().access != Access::Sequential;
+ }
return ExternalIoStatementBase::EndIoStatement();
}
@@ -969,7 +973,7 @@
: "ASCII";
break;
case HashInquiryKeyword("FORM"):
- str = !unit().isUnformatted ? "UNKNOWN"
+ str = !unit().isUnformatted ? "UNDEFINED"
: *unit().isUnformatted ? "UNFORMATTED"
: "FORMATTED";
break;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108990.369683.patch
Type: text/x-patch
Size: 770 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20210831/dd85f269/attachment.bin>
More information about the flang-commits
mailing list