[flang-commits] [PATCH] D124279: [flang][runtime] Accept "." as REAL input

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Apr 22 10:45:25 PDT 2022


klausler created this revision.
klausler added a reviewer: vdonaldson.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.

".", possibly followed by an exponent, is a valid REAL input value (meaning zero).


https://reviews.llvm.org/D124279

Files:
  flang/runtime/edit-input.cpp


Index: flang/runtime/edit-input.cpp
===================================================================
--- flang/runtime/edit-input.cpp
+++ flang/runtime/edit-input.cpp
@@ -58,15 +58,12 @@
 // Returns true if there's a '-' sign.
 static bool ScanNumericPrefix(IoStatementState &io, const DataEdit &edit,
     std::optional<char32_t> &next, std::optional<int> &remaining) {
-  bool bzMode{(edit.modes.editingFlags & blankZero) != 0};
-  next = io.PrepareInput(edit, remaining, !bzMode);
+  next = io.PrepareInput(edit, remaining);
   bool negative{false};
   if (next) {
     negative = *next == '-';
     if (negative || *next == '+') {
-      if (!bzMode) {
-        io.SkipSpaces(remaining);
-      }
+      io.SkipSpaces(remaining);
       next = io.NextInField(remaining, edit);
     }
   }
@@ -189,7 +186,6 @@
       first == 'D' || first == 'Q') {
     Put('.'); // input field is normalized to a fraction
     auto start{got};
-    bool anyDigit{false};
     for (; next; next = io.NextInField(remaining, edit)) {
       char32_t ch{*next};
       if (ch == ' ' || ch == '\t') {
@@ -200,10 +196,8 @@
         }
       }
       if (ch == '0' && got == start && !decimalPoint) {
-        anyDigit = true;
         // omit leading zeroes before the decimal
       } else if (ch >= '0' && ch <= '9') {
-        anyDigit = true;
         Put(ch);
       } else if (ch == decimal && !decimalPoint) {
         // the decimal point is *not* copied to the buffer
@@ -213,11 +207,10 @@
       }
     }
     if (got == start) {
-      if (anyDigit) {
-        Put('0'); // emit at least one digit
-      } else {
-        return 0; // no digits, invalid input
-      }
+      // Nothing but zeroes and maybe a decimal point.  F'2018 requires
+      // at least one digit, but F'77 did not, and a bare "." shows up in
+      // the FCVS suite.
+      Put('0'); // emit at least one digit
     }
     if (next &&
         (*next == 'e' || *next == 'E' || *next == 'd' || *next == 'D' ||


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124279.424532.patch
Type: text/x-patch
Size: 1982 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220422/2a9e4507/attachment-0001.bin>


More information about the flang-commits mailing list