[flang-commits] [flang] 839f0ab - [flang][runtime] Accept "." as REAL input

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Fri Apr 22 12:38:16 PDT 2022


Author: Peter Klausler
Date: 2022-04-22T12:38:07-07:00
New Revision: 839f0abdaaa63569d8e153b553445b6f2a8aaa0f

URL: https://github.com/llvm/llvm-project/commit/839f0abdaaa63569d8e153b553445b6f2a8aaa0f
DIFF: https://github.com/llvm/llvm-project/commit/839f0abdaaa63569d8e153b553445b6f2a8aaa0f.diff

LOG: [flang][runtime] Accept "." as REAL input

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

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

Added: 
    

Modified: 
    flang/runtime/edit-input.cpp

Removed: 
    


################################################################################
diff  --git a/flang/runtime/edit-input.cpp b/flang/runtime/edit-input.cpp
index 04db2e58e4820..fc5ee379e5df7 100644
--- a/flang/runtime/edit-input.cpp
+++ b/flang/runtime/edit-input.cpp
@@ -186,7 +186,6 @@ static int ScanRealInput(char *buffer, int bufferSize, IoStatementState &io,
       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') {
@@ -197,10 +196,8 @@ static int ScanRealInput(char *buffer, int bufferSize, IoStatementState &io,
         }
       }
       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
@@ -210,11 +207,10 @@ static int ScanRealInput(char *buffer, int bufferSize, IoStatementState &io,
       }
     }
     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' ||


        


More information about the flang-commits mailing list