[flang-commits] [flang] [llvm] [flang][flang-rt] Implement F202X leading-zero control edit descriptors LZ, LZS, and LZP for formatted output (F, E, D, and G editing) (PR #183500)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Wed Mar 11 08:23:51 PDT 2026


================
@@ -419,10 +419,28 @@ RT_API_ATTRS bool RealOutputEditing<KIND>::EditEorDOutput(
     if (totalLength > width || !exponent) {
       return EmitRepeated(io_, '*', width);
     }
-    if (totalLength < width && digitsBeforePoint == 0 &&
-        zeroesBeforePoint == 0) {
-      zeroesBeforePoint = 1;
-      ++totalLength;
+    if (digitsBeforePoint == 0 && zeroesBeforePoint == 0 && scale <= 0) {
+      // Optional leading zero position (F202X leading zero control).
+      // When scale > 0 (kP with k > 0), digits are moved before the decimal
+      // point, so the leading zero position is not optional -- skip this.
+      // Value has no digits before the decimal point: "0.xxxE+yy" vs ".xxxE+yy"
+      switch (edit.modes.leadingZero) {
+      case MutableModes::LeadingZeroMode::Print:
----------------
klausler wrote:

This isn't how the edit descriptors' behaviors are defined in 13.8.5.  Please conform to the standard when adding new standard features.  LZP should behave in the way that you defined LZ, and LZ should behave like LZS or LZP.

https://github.com/llvm/llvm-project/pull/183500


More information about the flang-commits mailing list