[flang-commits] [PATCH] D151738: [flang] Detect output field width overflow for Inf/NaN

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Wed May 31 09:09:05 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG763e036cc912: [flang] Detect output field width overflow for Inf/NaN (authored by klausler).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151738

Files:
  flang/runtime/edit-output.cpp


Index: flang/runtime/edit-output.cpp
===================================================================
--- flang/runtime/edit-output.cpp
+++ flang/runtime/edit-output.cpp
@@ -320,8 +320,12 @@
     decimal::ConversionToDecimalResult converted{
         Convert(significantDigits, edit.modes.round, flags)};
     if (IsInfOrNaN(converted)) {
-      return EmitPrefix(edit, converted.length, editWidth) &&
-          EmitAscii(io_, converted.str, converted.length) && EmitSuffix(edit);
+      return editWidth > 0 &&
+              converted.length > static_cast<std::size_t>(editWidth)
+          ? EmitRepeated(io_, '*', editWidth)
+          : EmitPrefix(edit, converted.length, editWidth) &&
+              EmitAscii(io_, converted.str, converted.length) &&
+              EmitSuffix(edit);
     }
     if (!IsZero()) {
       converted.decimalExponent -= scale;
@@ -415,8 +419,12 @@
     decimal::ConversionToDecimalResult converted{
         Convert(extraDigits + fracDigits, rounding, flags)};
     if (IsInfOrNaN(converted)) {
-      return EmitPrefix(edit, converted.length, editWidth) &&
-          EmitAscii(io_, converted.str, converted.length) && EmitSuffix(edit);
+      return editWidth > 0 &&
+              converted.length > static_cast<std::size_t>(editWidth)
+          ? EmitRepeated(io_, '*', editWidth)
+          : EmitPrefix(edit, converted.length, editWidth) &&
+              EmitAscii(io_, converted.str, converted.length) &&
+              EmitSuffix(edit);
     }
     int expo{converted.decimalExponent + edit.modes.scale /*kP*/};
     int signLength{*converted.str == '-' || *converted.str == '+' ? 1 : 0};


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151738.527077.patch
Type: text/x-patch
Size: 1638 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230531/61b4d68d/attachment-0001.bin>


More information about the flang-commits mailing list