[flang-commits] [flang] [flang][runtime] Don't prematurely end formatted integer input (PR #76643)

via flang-commits flang-commits at lists.llvm.org
Sat Dec 30 16:31:17 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-runtime

Author: Peter Klausler (klausler)

<details>
<summary>Changes</summary>

When an input data-list has more items than can be read by a format from the input record (e.g., "(4I5)" reading "1 2"), don't return false from EditIntegerInput() just because nothing was read -- that will prevent later items from being set to zero, as they should be.  Return true unless nothing was read and there is some kind of error pending.

Fixes llvm-error-tests/Fortran/gfortran/regression/pr478478.f90.

---
Full diff: https://github.com/llvm/llvm-project/pull/76643.diff


1 Files Affected:

- (modified) flang/runtime/edit-input.cpp (+4-2) 


``````````diff
diff --git a/flang/runtime/edit-input.cpp b/flang/runtime/edit-input.cpp
index 2b809749067772..ce55a03094841c 100644
--- a/flang/runtime/edit-input.cpp
+++ b/flang/runtime/edit-input.cpp
@@ -243,10 +243,12 @@ bool EditIntegerInput(
   if (sign == '-') {
     value = -value;
   }
-  if (any || !io.GetConnectionState().IsAtEOF()) {
+  if (any || !io.GetIoErrorHandler().InError()) {
     std::memcpy(n, &value, kind); // a blank field means zero
+    return true;
+  } else {
+    return false;
   }
-  return any;
 }
 
 // Parses a REAL input number from the input source as a normalized

``````````

</details>


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


More information about the flang-commits mailing list