https://gcc.gnu.org/g:34c113107dc830f36da86bbd454d9b34dd5761dc

commit 34c113107dc830f36da86bbd454d9b34dd5761dc
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Fri Feb 7 14:38:51 2025 +0100

    Modifications mineures

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

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 545a88c13290..e0412b22b170 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -1514,7 +1514,10 @@ static void
 conv_shift_descriptor_lbound (stmtblock_t* block, tree from_desc, tree 
to_desc, int dim,
                              tree new_lbound, tree offset, bool 
relative_offset)
 {
+  /* Set lbound to the value we want.  */
   new_lbound = fold_convert (gfc_array_index_type, new_lbound);
+  new_lbound = gfc_evaluate_now (new_lbound, block);
+  gfc_conv_descriptor_lbound_set (block, to_desc, gfc_rank_cst[dim], 
new_lbound);
 
   tree lbound = gfc_conv_descriptor_lbound_get (from_desc, gfc_rank_cst[dim]);
   tree ubound = gfc_conv_descriptor_ubound_get (from_desc, gfc_rank_cst[dim]);
@@ -1526,9 +1529,9 @@ conv_shift_descriptor_lbound (stmtblock_t* block, tree 
from_desc, tree to_desc,
 
   /* Shift ubound and offset accordingly.  This has to be done before
      updating the lbound, as they depend on the lbound expression!  */
-  ubound = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
-                           ubound, diff);
-  gfc_conv_descriptor_ubound_set (block, to_desc, gfc_rank_cst[dim], ubound);
+  tree tmp1 = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
+                              ubound, diff);
+  gfc_conv_descriptor_ubound_set (block, to_desc, gfc_rank_cst[dim], tmp1);
 
   tree offs_diff;
   if (relative_offset)
@@ -1538,12 +1541,9 @@ conv_shift_descriptor_lbound (stmtblock_t* block, tree 
from_desc, tree to_desc,
 
   offs_diff = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
                               offs_diff, stride);
-  tree tmp = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
-                             offset, offs_diff);
-  gfc_add_modify (block, offset, tmp);
-
-  /* Finally set lbound to value we want.  */
-  gfc_conv_descriptor_lbound_set (block, to_desc, gfc_rank_cst[dim], 
new_lbound);
+  tree tmp2 = fold_build2_loc (input_location, MINUS_EXPR, 
gfc_array_index_type,
+                              offset, offs_diff);
+  gfc_add_modify (block, offset, tmp2);
 
   if (from_desc != to_desc)
     gfc_conv_descriptor_stride_set (block, to_desc, gfc_rank_cst[dim], stride);

Reply via email to