[flang-commits] [flang] 28b5e99 - [flang][runtime] (G0) for CHARACTER means (A), not (A0)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Mon May 9 13:00:26 PDT 2022


Author: Peter Klausler
Date: 2022-05-09T13:00:15-07:00
New Revision: 28b5e99a4c84f687b4c43c46a293e9f4b4cf6986

URL: https://github.com/llvm/llvm-project/commit/28b5e99a4c84f687b4c43c46a293e9f4b4cf6986
DIFF: https://github.com/llvm/llvm-project/commit/28b5e99a4c84f687b4c43c46a293e9f4b4cf6986.diff

LOG: [flang][runtime] (G0) for CHARACTER means (A), not (A0)

I'm emitting zero characters for (G0) formatting of CHARACTER values
instead of using their lengths to determine the output field width.

Differential Revision: https://reviews.llvm.org/D125056

Added: 
    

Modified: 
    flang/runtime/edit-output.cpp

Removed: 
    


################################################################################
diff  --git a/flang/runtime/edit-output.cpp b/flang/runtime/edit-output.cpp
index 842ee837d69e..eca27e3e2c0c 100644
--- a/flang/runtime/edit-output.cpp
+++ b/flang/runtime/edit-output.cpp
@@ -627,9 +627,15 @@ bool ListDirectedCharacterOutput(IoStatementState &io,
 template <typename CHAR>
 bool EditCharacterOutput(IoStatementState &io, const DataEdit &edit,
     const CHAR *x, std::size_t length) {
+  int len{static_cast<int>(length)};
+  int width{edit.width.value_or(len)};
   switch (edit.descriptor) {
   case 'A':
+    break;
   case 'G':
+    if (width == 0) {
+      width = len;
+    }
     break;
   case 'B':
     return EditBOZOutput<1>(io, edit,
@@ -646,8 +652,6 @@ bool EditCharacterOutput(IoStatementState &io, const DataEdit &edit,
         edit.descriptor);
     return false;
   }
-  int len{static_cast<int>(length)};
-  int width{edit.width.value_or(len)};
   return io.EmitRepeated(' ', std::max(0, width - len)) &&
       io.EmitEncoded(x, std::min(width, len));
 }


        


More information about the flang-commits mailing list