[flang-commits] [PATCH] D88618: [flang] Fix Gw.d format output

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Wed Sep 30 18:03:03 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG4fb679d3b159: [flang] Fix Gw.d format output (authored by klausler).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88618/new/

https://reviews.llvm.org/D88618

Files:
  flang/runtime/edit-output.cpp
  flang/runtime/format-implementation.h


Index: flang/runtime/format-implementation.h
===================================================================
--- flang/runtime/format-implementation.h
+++ flang/runtime/format-implementation.h
@@ -97,7 +97,7 @@
   }
   int result{0};
   bool negate{ch == '-'};
-  if (negate) {
+  if (negate || ch == '+') {
     firstCh = '\0';
     ch = PeekNext();
   }
Index: flang/runtime/edit-output.cpp
===================================================================
--- flang/runtime/edit-output.cpp
+++ flang/runtime/edit-output.cpp
@@ -330,17 +330,17 @@
 template <int binaryPrecision>
 DataEdit RealOutputEditing<binaryPrecision>::EditForGOutput(DataEdit edit) {
   edit.descriptor = 'E';
-  if (!edit.width.has_value() ||
-      (*edit.width > 0 && edit.digits.value_or(-1) == 0)) {
+  int significantDigits{
+      edit.digits.value_or(BinaryFloatingPoint::decimalPrecision)}; // 'd'
+  if (!edit.width.has_value() || (*edit.width > 0 && significantDigits == 0)) {
     return edit; // Gw.0 -> Ew.0 for w > 0
   }
-  decimal::ConversionToDecimalResult converted{Convert(1, edit)};
+  decimal::ConversionToDecimalResult converted{
+      Convert(significantDigits, edit)};
   if (IsInfOrNaN(converted)) {
     return edit;
   }
   int expo{IsZero() ? 1 : converted.decimalExponent}; // 's'
-  int significantDigits{
-      edit.digits.value_or(BinaryFloatingPoint::decimalPrecision)}; // 'd'
   if (expo < 0 || expo > significantDigits) {
     return edit; // Ew.d
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88618.295448.patch
Type: text/x-patch
Size: 1473 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20201001/2f49b40b/attachment.bin>


More information about the flang-commits mailing list