[flang-commits] [flang] 06b3144 - [flang][runtime] Clear last record in internal WRITE even if nothing … (#74528)

via flang-commits flang-commits at lists.llvm.org
Mon Dec 11 12:32:33 PST 2023


Author: Peter Klausler
Date: 2023-12-11T12:32:29-08:00
New Revision: 06b3144c3f533c82ee9ae6afa68ff41566eb2df5

URL: https://github.com/llvm/llvm-project/commit/06b3144c3f533c82ee9ae6afa68ff41566eb2df5
DIFF: https://github.com/llvm/llvm-project/commit/06b3144c3f533c82ee9ae6afa68ff41566eb2df5.diff

LOG: [flang][runtime] Clear last record in internal WRITE even if nothing … (#74528)

…was written

At the end of an internal output statement, The I/O runtime fills (the
remainder of) the current record with blanks if it's the only record or
if anything had been written to it. This turns out to be wrong in the
case of a format that ends with an explicit advance to the next record,
which needs to be cleared even if nothing has been written.

Fixes llvm-test-suite/Fortran/gfortran/regression/arrayio_1.f90.

Added: 
    

Modified: 
    flang/runtime/internal-unit.cpp

Removed: 
    


################################################################################
diff  --git a/flang/runtime/internal-unit.cpp b/flang/runtime/internal-unit.cpp
index aa7130f3a6a53d..e3fffaa6f378ff 100644
--- a/flang/runtime/internal-unit.cpp
+++ b/flang/runtime/internal-unit.cpp
@@ -43,11 +43,9 @@ InternalDescriptorUnit<DIR>::InternalDescriptorUnit(
 
 template <Direction DIR> void InternalDescriptorUnit<DIR>::EndIoStatement() {
   if constexpr (DIR == Direction::Output) {
-    // Clear the remainder of the current record if anything was written
-    // to it, or if it is the only record.
+    // Clear the remainder of the current record.
     auto end{endfileRecordNumber.value_or(0)};
-    if (currentRecordNumber < end &&
-        (end == 2 || furthestPositionInRecord > 0)) {
+    if (currentRecordNumber < end) {
       BlankFillOutputRecord();
     }
   }


        


More information about the flang-commits mailing list