[flang-commits] [flang] [flang][runtime] 'A' output editing for LOGICAL (PR #89817)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Tue Apr 23 12:55:40 PDT 2024


https://github.com/klausler created https://github.com/llvm/llvm-project/pull/89817

We support 'A' output editing for INTEGER and REAL as an extension; it turns out to be used as well for LOGICAL in application code.

>From 7d9e7f627bf7e7ac904b464f9dce9f759eb1b7b0 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Tue, 23 Apr 2024 12:52:52 -0700
Subject: [PATCH] [flang][runtime] 'A' output editing for LOGICAL

We support 'A' output editing for INTEGER and REAL as an
extension; it turns out to be used as well for LOGICAL in
application code.
---
 flang/runtime/edit-output.cpp                |  5 +++++
 flang/unittests/Runtime/RuntimeCrashTest.cpp | 10 ----------
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/flang/runtime/edit-output.cpp b/flang/runtime/edit-output.cpp
index a06ed258f0f1d2..c3e11e6e4ce6de 100644
--- a/flang/runtime/edit-output.cpp
+++ b/flang/runtime/edit-output.cpp
@@ -822,6 +822,11 @@ RT_API_ATTRS bool EditLogicalOutput(
   case 'Z':
     return EditBOZOutput<4>(io, edit,
         reinterpret_cast<const unsigned char *>(&truth), sizeof truth);
+  case 'A': { // legacy extension
+    int truthBits{truth};
+    return EditCharacterOutput(
+        io, edit, reinterpret_cast<char *>(&truthBits), sizeof truthBits);
+  }
   default:
     io.GetIoErrorHandler().SignalError(IostatErrorInFormat,
         "Data edit descriptor '%c' may not be used with a LOGICAL data item",
diff --git a/flang/unittests/Runtime/RuntimeCrashTest.cpp b/flang/unittests/Runtime/RuntimeCrashTest.cpp
index 0f25cc0ee8035b..a649051fdca0c5 100644
--- a/flang/unittests/Runtime/RuntimeCrashTest.cpp
+++ b/flang/unittests/Runtime/RuntimeCrashTest.cpp
@@ -53,16 +53,6 @@ TEST(TestTerminator, CheckFailedTest) {
 //------------------------------------------------------------------------------
 struct TestIOCrash : CrashHandlerFixture {};
 
-TEST(TestIOCrash, FormatDescriptorWriteMismatchTest) {
-  static constexpr int bufferSize{4};
-  static char buffer[bufferSize];
-  static const char *format{"(A4)"};
-  auto *cookie{IONAME(BeginInternalFormattedOutput)(
-      buffer, bufferSize, format, std::strlen(format))};
-  ASSERT_DEATH(IONAME(OutputLogical)(cookie, true),
-      "Data edit descriptor 'A' may not be used with a LOGICAL data item");
-}
-
 TEST(TestIOCrash, InvalidFormatCharacterTest) {
   static constexpr int bufferSize{1};
   static char buffer[bufferSize];



More information about the flang-commits mailing list