[llvm] [flang][runtime] Remove redundant initialization (PR #150984)

Peter Klausler via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 28 09:14:25 PDT 2025


https://github.com/klausler created https://github.com/llvm/llvm-project/pull/150984

The assignment to mutableModes() in BeginIoStatement() is redundant, since the mutableModes_ data member is initialized by the constructors of the two classes that now have one.  Remove the assignment to avoid confusion.

Also restores the original OutputStatementState base class name after a recent patch that needlessly changed it to something equivalent but less readable.

>From 0478c49dc79e68b456f775e70da289cc2a415e3c Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Mon, 28 Jul 2025 09:08:44 -0700
Subject: [PATCH] [flang][runtime] Remove redundant initialization

The assignment to mutableModes() in BeginIoStatement() is redundant,
since the mutableModes_ data member is initialized by the constructors
of the two classes that now have one.  Remove the assignment to
avoid confusion.

Also restores the original OutputStatementState base class name
after a recent patch that needlessly changed it to something
equivalent but less readable.
---
 flang-rt/include/flang-rt/runtime/io-stmt.h | 2 +-
 flang-rt/lib/runtime/unit.h                 | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/flang-rt/include/flang-rt/runtime/io-stmt.h b/flang-rt/include/flang-rt/runtime/io-stmt.h
index 95b2ee7370981..1d680d7d2ffb3 100644
--- a/flang-rt/include/flang-rt/runtime/io-stmt.h
+++ b/flang-rt/include/flang-rt/runtime/io-stmt.h
@@ -856,7 +856,7 @@ class InquireUnconnectedFileState : public NoUnitIoStatementState {
 };
 
 class InquireIOLengthState : public NoUnitIoStatementState,
-                             public IoDirectionState<Direction::Output> {
+                             public OutputStatementState {
 public:
   RT_API_ATTRS InquireIOLengthState(
       const char *sourceFile = nullptr, int sourceLine = 0);
diff --git a/flang-rt/lib/runtime/unit.h b/flang-rt/lib/runtime/unit.h
index 9aec9b1659576..f266a486bb708 100644
--- a/flang-rt/lib/runtime/unit.h
+++ b/flang-rt/lib/runtime/unit.h
@@ -161,9 +161,6 @@ class ExternalFileUnit : public ConnectionState,
     lock_.Take();
 #endif
     A &state{u_.emplace<A>(std::forward<X>(xs)...)};
-    if constexpr (!std::is_same_v<A, OpenStatementState>) {
-      state.mutableModes() = ConnectionState::modes;
-    }
     directAccessRecWasSet_ = false;
     io_.emplace(state);
     return *io_;



More information about the llvm-commits mailing list