https://gcc.gnu.org/g:409d07985630d13c96ab375cbaaff938c93efc56

commit 409d07985630d13c96ab375cbaaff938c93efc56
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Sat Aug 16 19:16:15 2025 +0200

    Refactor set_dimension_fields descriptor_init_count
    
    Correction régression class_allocate_22

Diff:
---
 gcc/fortran/trans-descriptor.cc | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 7607d7f24849..59efc1b96bff 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -2785,15 +2785,8 @@ gfc_descriptor_init_count (tree descriptor, int rank, 
int corank,
              ubound = lower[n];
            }
        }
-      gfc_conv_descriptor_lbound_set (descriptor_block, descriptor,
-                                     gfc_rank_cst[n], se.expr);
       conv_lbound = se.expr;
-
-      /* Work out the offset for this component.  */
-      tmp = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
-                            se.expr, stride);
-      offset = fold_build2_loc (input_location, MINUS_EXPR,
-                               gfc_array_index_type, offset, tmp);
+      conv_lbound = gfc_evaluate_now (conv_lbound, pblock);
 
       /* Set upper bound.  */
       gfc_init_se (&se, NULL);
@@ -2829,13 +2822,11 @@ gfc_descriptor_init_count (tree descriptor, int rank, 
int corank,
          if (ubound->expr_type == EXPR_FUNCTION)
            se.expr = gfc_evaluate_now (se.expr, pblock);
        }
-      gfc_conv_descriptor_ubound_set (descriptor_block, descriptor,
-                                     gfc_rank_cst[n], se.expr);
       conv_ubound = se.expr;
+      conv_ubound = gfc_evaluate_now (conv_ubound, pblock);
 
-      /* Store the stride.  */
-      gfc_conv_descriptor_stride_set (descriptor_block, descriptor,
-                                     gfc_rank_cst[n], stride);
+      set_dimension_fields (descriptor_block, descriptor, gfc_rank_cst[n],
+                           conv_lbound, conv_ubound, stride, &offset);
 
       /* Calculate size and check whether extent is negative.  */
       size = gfc_conv_array_extent_dim (conv_lbound, conv_ubound, &empty_cond);
@@ -2919,7 +2910,6 @@ gfc_descriptor_init_count (tree descriptor, int rank, int 
corank,
     return gfc_index_one_node;
 
   /* Update the array descriptor with the offset and the span.  */
-  offset = gfc_evaluate_now (offset, pblock);
   gfc_conv_descriptor_offset_set (descriptor_block, descriptor, offset);
   tmp = fold_convert (gfc_array_index_type, element_size);
   gfc_conv_descriptor_span_set (descriptor_block, descriptor, tmp);

Reply via email to