[flang-commits] [flang] b83242e - [flang] Support legacy usage of 'A' edit descriptors for integer & real
peter klausler via flang-commits
flang-commits at lists.llvm.org
Fri Oct 22 16:04:47 PDT 2021
Author: peter klausler
Date: 2021-10-22T16:02:33-07:00
New Revision: b83242e20e099c9cc4ba90a63abda8ba6e2f32d5
URL: https://github.com/llvm/llvm-project/commit/b83242e20e099c9cc4ba90a63abda8ba6e2f32d5
DIFF: https://github.com/llvm/llvm-project/commit/b83242e20e099c9cc4ba90a63abda8ba6e2f32d5.diff
LOG: [flang] Support legacy usage of 'A' edit descriptors for integer & real
The 'A' edit descriptor once served as a form of raw I/O of bytes
to/from variables that weren't of type CHARACTER (which itself
didn't exist until F'77). This usage was especially common for
output of numeric variables that had been initialized with Hollerith.
Differential Revision: https://reviews.llvm.org/D112346
Added:
Modified:
flang/runtime/edit-input.cpp
flang/runtime/edit-output.cpp
flang/unittests/Runtime/RuntimeCrashTest.cpp
Removed:
################################################################################
diff --git a/flang/runtime/edit-input.cpp b/flang/runtime/edit-input.cpp
index c632865aa13a1..19aa56a84932e 100644
--- a/flang/runtime/edit-input.cpp
+++ b/flang/runtime/edit-input.cpp
@@ -83,6 +83,9 @@ bool EditIntegerInput(
return EditBOZInput(io, edit, n, 8, kind << 3);
case 'Z':
return EditBOZInput(io, edit, n, 16, kind << 3);
+ case 'A': // legacy extension
+ return EditDefaultCharacterInput(
+ io, edit, reinterpret_cast<char *>(n), kind);
default:
io.GetIoErrorHandler().SignalError(IostatErrorInFormat,
"Data edit descriptor '%c' may not be used with an INTEGER data item",
@@ -323,6 +326,9 @@ bool EditRealInput(IoStatementState &io, const DataEdit &edit, void *n) {
case 'Z':
return EditBOZInput(
io, edit, n, 16, common::BitsForBinaryPrecision(binaryPrecision));
+ case 'A': // legacy extension
+ return EditDefaultCharacterInput(
+ io, edit, reinterpret_cast<char *>(n), KIND);
default:
io.GetIoErrorHandler().SignalError(IostatErrorInFormat,
"Data edit descriptor '%c' may not be used for REAL input",
diff --git a/flang/runtime/edit-output.cpp b/flang/runtime/edit-output.cpp
index f599cb0d2c96a..09dd40674c380 100644
--- a/flang/runtime/edit-output.cpp
+++ b/flang/runtime/edit-output.cpp
@@ -52,6 +52,9 @@ bool EditIntegerOutput(IoStatementState &io, const DataEdit &edit,
*--p = digit >= 10 ? 'A' + (digit - 10) : '0' + digit;
}
break;
+ case 'A': // legacy extension
+ return EditDefaultCharacterOutput(
+ io, edit, reinterpret_cast<char *>(&n), sizeof n);
default:
io.GetIoErrorHandler().Crash(
"Data edit descriptor '%c' may not be used with an INTEGER data item",
@@ -402,6 +405,9 @@ template <int KIND> bool RealOutputEditing<KIND>::Edit(const DataEdit &edit) {
decimal::BinaryFloatingPointNumber<binaryPrecision>{x_}.raw()));
case 'G':
return Edit(EditForGOutput(edit));
+ case 'A': // legacy extension
+ return EditDefaultCharacterOutput(
+ io_, edit, reinterpret_cast<char *>(&x_), sizeof x_);
default:
if (edit.IsListDirected()) {
return EditListDirectedOutput(edit);
diff --git a/flang/unittests/Runtime/RuntimeCrashTest.cpp b/flang/unittests/Runtime/RuntimeCrashTest.cpp
index ce573095b1cd5..c6f43582b4c89 100644
--- a/flang/unittests/Runtime/RuntimeCrashTest.cpp
+++ b/flang/unittests/Runtime/RuntimeCrashTest.cpp
@@ -57,8 +57,8 @@ TEST(TestIOCrash, FormatDescriptorWriteMismatchTest) {
static const char *format{"(A4)"};
auto *cookie{IONAME(BeginInternalFormattedOutput)(
buffer, bufferSize, format, std::strlen(format))};
- ASSERT_DEATH(IONAME(OutputInteger64)(cookie, 0xfeedface),
- "Data edit descriptor 'A' may not be used with an INTEGER data item");
+ ASSERT_DEATH(IONAME(OutputLogical)(cookie, true),
+ "Data edit descriptor 'A' may not be used with a LOGICAL data item");
}
TEST(TestIOCrash, InvalidFormatCharacterTest) {
More information about the flang-commits
mailing list