[flang-commits] [PATCH] D154379: [flang][runtime] Allow OPEN(n, ENCODING=) to change the encoding
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Mon Jul 3 11:33:05 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc9b31dae56f1: [flang][runtime] Allow OPEN(n,ENCODING=) to change the encoding (authored by klausler).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154379/new/
https://reviews.llvm.org/D154379
Files:
flang/docs/Extensions.md
flang/runtime/io-api.cpp
Index: flang/runtime/io-api.cpp
===================================================================
--- flang/runtime/io-api.cpp
+++ flang/runtime/io-api.cpp
@@ -927,25 +927,20 @@
io.GetIoErrorHandler().Crash(
"SetEncoding() called after GetNewUnit() for an OPEN statement");
}
- bool isUTF8{false};
+ // Allow the encoding to be changed on an open unit -- it's
+ // useful and safe.
static const char *keywords[]{"UTF-8", "DEFAULT", nullptr};
switch (IdentifyValue(keyword, length, keywords)) {
case 0:
- isUTF8 = true;
+ open->unit().isUTF8 = true;
break;
case 1:
- isUTF8 = false;
+ open->unit().isUTF8 = false;
break;
default:
open->SignalError(IostatErrorInKeyword, "Invalid ENCODING='%.*s'",
static_cast<int>(length), keyword);
}
- if (isUTF8 != open->unit().isUTF8) {
- if (open->wasExtant()) {
- open->SignalError("ENCODING= may not be changed on an open unit");
- }
- open->unit().isUTF8 = isUTF8;
- }
return true;
}
Index: flang/docs/Extensions.md
===================================================================
--- flang/docs/Extensions.md
+++ flang/docs/Extensions.md
@@ -592,3 +592,7 @@
* `EXTENDS_TYPE_OF()` returns `.TRUE.` if both of its arguments have the
same type, a case that is technically implementation-defined.
+
+* `ENCODING=` is not in the list of changeable modes on an I/O unit,
+ but every Fortran compiler allows the encoding to be changed on an
+ open unit.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154379.536855.patch
Type: text/x-patch
Size: 1497 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230703/13ee3be5/attachment-0001.bin>
More information about the flang-commits
mailing list