https://gcc.gnu.org/g:75ff508fff8aedf973c6b6a381d661bb91ccc7c0

commit 75ff508fff8aedf973c6b6a381d661bb91ccc7c0
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Wed Jul 23 16:09:55 2025 +0200

    Suppression argument nelens gfc_array_allocate

Diff:
---
 gcc/fortran/trans-array.cc | 20 +++++++++-----------
 gcc/fortran/trans-array.h  |  5 ++---
 gcc/fortran/trans-expr.cc  |  1 -
 gcc/fortran/trans-stmt.cc  |  7 ++-----
 4 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 97d3179a9268..25b57039faa7 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -5730,8 +5730,8 @@ static tree
 gfc_array_init_size (tree descriptor, int rank, int corank, gfc_expr ** lower,
                     gfc_expr ** upper, stmtblock_t * pblock,
                     stmtblock_t * descriptor_block, tree * overflow,
-                    tree expr3_elem_size, tree *nelems, gfc_expr *expr3,
-                    tree expr3_desc, bool e3_has_nodescriptor, gfc_expr *expr,
+                    tree expr3_elem_size, gfc_expr *expr3, tree expr3_desc,
+                    bool e3_has_nodescriptor, gfc_expr *expr,
                     tree element_size, bool explicit_ts)
 {
   tree type;
@@ -5977,7 +5977,6 @@ gfc_array_init_size (tree descriptor, int rank, int 
corank, gfc_expr ** lower,
   tmp = fold_convert (gfc_array_index_type, element_size);
   gfc_conv_descriptor_span_set (descriptor_block, descriptor, tmp);
 
-  *nelems = gfc_evaluate_now (stride, pblock);
   stride = fold_convert (size_type_node, stride);
 
   /* First check for overflow. Since an array of type character can
@@ -6060,9 +6059,8 @@ retrieve_last_ref (gfc_ref **ref_in, gfc_ref 
**prev_ref_in)
 bool
 gfc_array_allocate (gfc_se * se, gfc_expr * expr, tree status, tree errmsg,
                    tree errlen, tree label_finish, tree expr3_elem_size,
-                   tree *nelems, gfc_expr *expr3, tree e3_arr_desc,
-                   bool e3_has_nodescriptor, gfc_omp_namelist *omp_alloc,
-                   bool explicit_ts)
+                   gfc_expr *expr3, tree e3_arr_desc, bool e3_has_nodescriptor,
+                   gfc_omp_namelist *omp_alloc, bool explicit_ts)
 {
   tree tmp;
   tree pointer;
@@ -6193,11 +6191,11 @@ gfc_array_allocate (gfc_se * se, gfc_expr * expr, tree 
status, tree errmsg,
      pointer components in derived types.  */
   size = gfc_array_init_size (se->expr, alloc_w_e3_arr_spec ? expr->rank
                                                           : ref->u.ar.as->rank,
-                             coarray ? ref->u.ar.as->corank : 0,
-                             lower, upper, &se->pre, &set_descriptor_block,
-                             &overflow, expr3_elem_size, nelems, expr3,
-                             e3_arr_desc, e3_has_nodescriptor, expr,
-                             element_size, explicit_ts);
+                             coarray ? ref->u.ar.as->corank : 0, lower, upper,
+                             &se->pre, &set_descriptor_block, &overflow,
+                             expr3_elem_size, expr3, e3_arr_desc,
+                             e3_has_nodescriptor, expr, element_size,
+                             explicit_ts);
 
   if (dimension)
     {
diff --git a/gcc/fortran/trans-array.h b/gcc/fortran/trans-array.h
index 7ef8c7a6aa5e..66e11d9d1f16 100644
--- a/gcc/fortran/trans-array.h
+++ b/gcc/fortran/trans-array.h
@@ -20,9 +20,8 @@ along with GCC; see the file COPYING3.  If not see
 
 /* Generate code to initialize and allocate an array.  Statements are added to
    se, which should contain an expression for the array descriptor.  */
-bool gfc_array_allocate (gfc_se *, gfc_expr *, tree, tree, tree, tree,
-                        tree, tree *, gfc_expr *, tree, bool,
-                        gfc_omp_namelist *, bool);
+bool gfc_array_allocate (gfc_se *, gfc_expr *, tree, tree, tree, tree, tree,
+                        gfc_expr *, tree, bool, gfc_omp_namelist *, bool);
 
 /* Allow the bounds of a loop to be set from a callee's array spec.  */
 void gfc_set_loop_bounds_from_array_spec (gfc_interface_mapping *,
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 8051289ddb80..d236d0fc2962 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -5376,7 +5376,6 @@ gfc_conv_subref_array_arg (gfc_se *se, gfc_expr * expr, 
int g77,
   tree tmp_index;
   tree tmp;
   tree base_type;
-  tree size;
   stmtblock_t body;
   int n;
   int dimen;
diff --git a/gcc/fortran/trans-stmt.cc b/gcc/fortran/trans-stmt.cc
index 8fedda1159d6..9376811fa70e 100644
--- a/gcc/fortran/trans-stmt.cc
+++ b/gcc/fortran/trans-stmt.cc
@@ -6706,7 +6706,6 @@ gfc_trans_allocate (gfc_code * code, gfc_omp_namelist 
*omp_allocate)
   stmtblock_t block;
   stmtblock_t post;
   stmtblock_t final_block;
-  tree nelems;
   bool upoly_expr, tmp_expr3_len_flag = false, al_len_needs_set, is_coarray;
   bool needs_caf_sync, caf_refs_comp;
   bool e3_has_nodescriptor = false;
@@ -7238,7 +7237,6 @@ gfc_trans_allocate (gfc_code * code, gfc_omp_namelist 
*omp_allocate)
         to handle the complete array allocation.  Only the element size
         needs to be provided, which is done most of the time by the
         pre-evaluation step.  */
-      nelems = NULL_TREE;
       if (expr3_len && (code->expr3->ts.type == BT_CHARACTER
                        || code->expr3->ts.type == BT_CLASS))
        {
@@ -7309,9 +7307,8 @@ gfc_trans_allocate (gfc_code * code, gfc_omp_namelist 
*omp_allocate)
 
        }
 
-      if (!gfc_array_allocate (&se, expr, stat, errmsg, errlen,
-                              label_finish, tmp, &nelems,
-                              e3rhs ? e3rhs : code->expr3,
+      if (!gfc_array_allocate (&se, expr, stat, errmsg, errlen, label_finish,
+                              tmp, e3rhs ? e3rhs : code->expr3,
                               e3_is == E3_DESC ? expr3 : NULL_TREE,
                               e3_has_nodescriptor, omp_alloc_item,
                               code->ext.alloc.ts.type != BT_UNKNOWN))

Reply via email to