[gcc(refs/users/mikael/heads/refactor_descriptor_v291.01)] Factorisation set_dimension_fields gfc_set_descriptor_with_shape

Mikael Morin via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:26a9384bcdc95d35d155cf40de5795066c1681a4

commit 26a9384bcdc95d35d155cf40de5795066c1681a4
Author: Mikael Morin <[email protected]>
Date:   Sat Aug 16 18:19:27 2025 +0200

    Factorisation set_dimension_fields gfc_set_descriptor_with_shape
    
    Correction régression c_f_pointer_tests_4

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 9e9e7931a9e5..43697a96328b 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -2009,15 +2009,12 @@ gfc_set_descriptor_with_shape (stmtblock_t *block, tree desc, tree ptr,
       gfc_conv_expr (&lowerse, lower);
       gfc_add_block_to_block (&body, &lowerse.pre);
       lbound = fold_convert (gfc_array_index_type, lowerse.expr);
+      lbound = gfc_evaluate_now (lbound, &body);
       gfc_add_block_to_block (&body, &lowerse.post);
     }
   else
     lbound = gfc_index_one_node;
 
-  /* Set bounds and stride.  */
-  gfc_conv_descriptor_lbound_set (&body, desc, dim, lbound);
-  gfc_conv_descriptor_stride_set (&body, desc, dim, stride);
-
   gfc_conv_expr (&shapese, shape);
   gfc_add_block_to_block (&body, &shapese.pre);
   tree shapeval = fold_convert (gfc_array_index_type, shapese.expr);
@@ -2026,29 +2023,22 @@ gfc_set_descriptor_with_shape (stmtblock_t *block, tree desc, tree ptr,
 			 lbound, gfc_index_one_node);
   tree ubound = fold_build2_loc (input_location, PLUS_EXPR,
 				 gfc_array_index_type, tmp, shapeval);
-  gfc_conv_descriptor_ubound_set (&body, desc, dim, ubound);
+  ubound = gfc_evaluate_now (ubound, &body);
   gfc_add_block_to_block (&body, &shapese.post);
 
-  /* Calculate offset.  */
-  tmp = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
-			 stride, lbound);
-  gfc_add_modify (&body, offset,
-		  fold_build2_loc (input_location, PLUS_EXPR,
-				   gfc_array_index_type, offset, tmp));
+  set_dimension_fields (&body, desc, dim, lbound, ubound, stride, offset);
 
   /* Update stride.  */
   gfc_add_modify (&body, stride,
 		  fold_build2_loc (input_location, MULT_EXPR,
 				   gfc_array_index_type, stride, shapeval));
+
   /* Finish scalarization loop.  */
   gfc_trans_scalarizing_loops (&loop, &body);
   gfc_add_block_to_block (block, &loop.pre);
   gfc_add_block_to_block (block, &loop.post);
   gfc_cleanup_loop (&loop);
 
-  gfc_add_modify (block, offset,
-		  fold_build1_loc (input_location, NEGATE_EXPR,
-				   gfc_array_index_type, offset));
   gfc_conv_descriptor_offset_set (block, desc, offset);
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.