https://gcc.gnu.org/g:3df7f5006e28abd5abe00e242b010355e107beec

commit 3df7f5006e28abd5abe00e242b010355e107beec
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Thu Apr 10 14:49:06 2025 +0200

    Correction ICEs ISO_Fortran_binding_17

Diff:
---
 gcc/fortran/trans-array.cc      | 15 ++++++---------
 gcc/fortran/trans-descriptor.cc |  4 ++--
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 00e262f7d02e..5014c1aa8731 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -3501,7 +3501,6 @@ conv_array_index (gfc_se * se, gfc_ss * ss, int dim, int 
i,
   tree index;
   tree descriptor;
   tree data;
-  tree offset;
 
   info = &ss->info->data.array;
 
@@ -3531,9 +3530,6 @@ conv_array_index (gfc_se * se, gfc_ss * ss, int dim, int 
i,
          gcc_assert (info->subscript[dim]
                      && info->subscript[dim]->info->type == GFC_SS_VECTOR);
 
-         offset = fold_build1_loc (input_location, NEGATE_EXPR,
-                                   gfc_array_index_type, se->loop->from[i]);
-
          descriptor = info->subscript[dim]->info->data.array.descriptor; 
          index = fold_convert_loc (input_location, gfc_array_index_type,
                                    se->loop->loopvar[i]);
@@ -3541,7 +3537,8 @@ conv_array_index (gfc_se * se, gfc_ss * ss, int dim, int 
i,
          /* Read the vector to get an index into info->descriptor.  */
          data = build_fold_indirect_ref_loc (input_location, 
                                              gfc_conv_array_data (descriptor));
-         index = gfc_build_array_ref (data, index, false, offset,
+         index = gfc_build_array_ref (data, index, false,
+                                      gfc_conv_array_lbound (descriptor, 0),
                                       gfc_conv_array_spacing (descriptor, 0));
          index = gfc_evaluate_now (index, &se->pre);
          index = fold_convert (gfc_array_index_type, index);
@@ -3612,7 +3609,8 @@ gfc_conv_scalarized_array_ref (gfc_se * se, gfc_array_ref 
* ar,
   bool non_negative_stride = tmp_array
                             || non_negative_strides_array_p (info->descriptor);
   se->expr = gfc_build_array_ref (base, index, non_negative_stride,
-                                 info->offset, info->spacing[ss->dim[0]]);
+                                 info->lbound[ss->dim[0]],
+                                 info->spacing[ss->dim[0]]);
 }
 
 
@@ -3694,8 +3692,8 @@ gfc_conv_array_ref (gfc_se * se, gfc_array_ref * ar, 
gfc_expr *expr,
       && ar->as->type != AS_DEFERRED)
     decl = sym->backend_decl;
 
-  tree array = gfc_conv_array_data (decl);
-  array = build_fold_indirect_ref_loc (input_location, array);
+  tree ptr = gfc_conv_array_data (decl);
+  tree array = build_fold_indirect_ref_loc (input_location, ptr);
 
   /* Calculate the offsets from all the dimensions.  Make sure to associate
      the final offset so that we form a chain of loop invariant summands.  */
@@ -3766,7 +3764,6 @@ gfc_conv_array_ref (gfc_se * se, gfc_array_ref * ar, 
gfc_expr *expr,
 
       tree spacing = gfc_conv_array_spacing (decl, n);
 
-      gcc_assert (GFC_ARRAY_TYPE_P (TREE_TYPE (array)));
       tmp = gfc_build_array_ref (array, indexse.expr,
                                 non_negative_strides_array_p (decl),
                                 lbound, spacing);
diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index f9cc1ae20066..699f29cd6137 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -965,7 +965,7 @@ gfc_build_desc_array_type (tree desc_type, tree etype, int 
dimen, tree * lbound,
   for (int i = 0; i < dimen; i++)
     {
       tree lower = lbound[i];
-      if (!INTEGER_CST_P (lower))
+      if (!lower)
        {
          tree root = build0 (PLACEHOLDER_EXPR, desc_type);
          tree dim = build_int_cst (integer_type_node, i);
@@ -973,7 +973,7 @@ gfc_build_desc_array_type (tree desc_type, tree etype, int 
dimen, tree * lbound,
        }
 
       tree upper = ubound[i];
-      if (!INTEGER_CST_P (lower))
+      if (!upper)
        {
          tree root = build0 (PLACEHOLDER_EXPR, desc_type);
          tree dim = build_int_cst (integer_type_node, i);

Reply via email to