[flang-commits] [PATCH] D112346: [flang] Support legacy usage of 'A' edit descriptors for integer & real

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Oct 22 14:48:45 PDT 2021


klausler created this revision.
klausler added a reviewer: vdonaldson.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
klausler requested review of this revision.

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.


https://reviews.llvm.org/D112346

Files:
  flang/runtime/edit-input.cpp
  flang/runtime/edit-output.cpp
  flang/unittests/Runtime/RuntimeCrashTest.cpp


Index: flang/unittests/Runtime/RuntimeCrashTest.cpp
===================================================================
--- flang/unittests/Runtime/RuntimeCrashTest.cpp
+++ flang/unittests/Runtime/RuntimeCrashTest.cpp
@@ -57,8 +57,8 @@
   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) {
Index: flang/runtime/edit-output.cpp
===================================================================
--- flang/runtime/edit-output.cpp
+++ flang/runtime/edit-output.cpp
@@ -52,6 +52,9 @@
       *--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 @@
             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);
Index: flang/runtime/edit-input.cpp
===================================================================
--- flang/runtime/edit-input.cpp
+++ flang/runtime/edit-input.cpp
@@ -83,6 +83,9 @@
     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 @@
   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",


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112346.381662.patch
Type: text/x-patch
Size: 2610 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20211022/99fbd278/attachment.bin>


More information about the flang-commits mailing list