[09/14] fortran: Inline variable definition

Message ID 20230713085236.330222-10-mikael@gcc.gnu.org
State Accepted
Headers
Series fortran: Use precalculated class container for deallocation [PR110618] |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Mikael Morin July 13, 2023, 8:52 a.m. UTC
  The variable has_finalizer is only used in one place, inline its
definition there.

gcc/fortran/ChangeLog:

	* trans.cc (gfc_add_finalizer_call): Inline definition of
	variable has_finalizer.  Merge nested conditions.
---
 gcc/fortran/trans.cc | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
  

Patch

diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc
index c6a65c87c5c..99677d37da7 100644
--- a/gcc/fortran/trans.cc
+++ b/gcc/fortran/trans.cc
@@ -1321,7 +1321,6 @@  gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2)
   tree tmp;
   gfc_ref *ref;
   gfc_expr *expr;
-  bool has_finalizer = false;
 
   if (!expr2 || (expr2->ts.type != BT_DERIVED && expr2->ts.type != BT_CLASS))
     return false;
@@ -1361,13 +1360,11 @@  gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2)
          ref->next = NULL;
        }
 
-  if (expr->ts.type == BT_CLASS)
-    {
-      has_finalizer = gfc_is_finalizable (expr->ts.u.derived, NULL);
-
-      if (!expr2->rank && !expr2->ref && CLASS_DATA (expr2->symtree->n.sym)->as)
-	expr->rank = CLASS_DATA (expr2->symtree->n.sym)->as->rank;
-    }
+  if (expr->ts.type == BT_CLASS
+      && !expr2->rank
+      && !expr2->ref
+      && CLASS_DATA (expr2->symtree->n.sym)->as)
+    expr->rank = CLASS_DATA (expr2->symtree->n.sym)->as->rank;
 
   stmtblock_t tmp_block;
   gfc_start_block (&tmp_block);
@@ -1398,7 +1395,8 @@  gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2)
 
   tmp = gfc_finish_block (&tmp_block);
 
-  if (expr->ts.type == BT_CLASS && !has_finalizer)
+  if (expr->ts.type == BT_CLASS
+      && !gfc_is_finalizable (expr->ts.u.derived, NULL))
     {
       tree cond;
       gfc_se se;