[flang-commits] [PATCH] D125048: [flang][runtime] Fix input of NAN(...) on non-fast path

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu May 5 15:11:01 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.

The closing parenthesis needs to be consumed when a NaN
with parenthesized (ignored) information is read on the
real input path that preprocesses input characters before
passing them to the decimal-to-binary converter.


https://reviews.llvm.org/D125048

Files:
  flang/runtime/edit-input.cpp


Index: flang/runtime/edit-input.cpp
===================================================================
--- flang/runtime/edit-input.cpp
+++ flang/runtime/edit-input.cpp
@@ -217,17 +217,19 @@
     if (next && *next == '(') { // NaN(...)
       Put('(');
       int depth{1};
-      do {
+      while (true) {
         next = io.NextInField(remaining, edit);
-        if (!next) {
+        if (depth == 0) {
           break;
+        } else if (!next) {
+          return 0; // error
         } else if (*next == '(') {
           ++depth;
         } else if (*next == ')') {
           --depth;
         }
         Put(*next);
-      } while (depth > 0);
+      }
     }
     exponent = 0;
   } else if (first == decimal || (first >= '0' && first <= '9') ||


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125048.427470.patch
Type: text/x-patch
Size: 759 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220505/b5c462f9/attachment.bin>


More information about the flang-commits mailing list