https://gcc.gnu.org/g:dc7afa2131a2ffaf46e6b2267be2a0e9f06c4719

commit dc7afa2131a2ffaf46e6b2267be2a0e9f06c4719
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Fri Apr 11 12:27:53 2025 +0200

    Correction ICE PR93308

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

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index c846b2c2a1ef..c8c8ab4b028e 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -6007,6 +6007,7 @@ gfc_conv_array_initializer (tree type, gfc_expr * expr)
 {
   gfc_constructor *c;
   tree tmp;
+  tree min_index = NULL_TREE;
   gfc_se se;
   tree index, range;
   vec<constructor_elt, va_gc> *v = NULL;
@@ -6043,6 +6044,9 @@ gfc_conv_array_initializer (tree type, gfc_expr * expr)
       break;
 
     case EXPR_ARRAY:
+      if (TYPE_DOMAIN (type))
+       min_index = TYPE_MIN_VALUE (TYPE_DOMAIN (type));
+
       /* Create a vector of all the elements.  */
       for (c = gfc_constructor_first (expr->value.constructor);
           c && c->expr; c = gfc_constructor_next (c))
@@ -6062,6 +6066,9 @@ gfc_conv_array_initializer (tree type, gfc_expr * expr)
             index = gfc_conv_mpz_to_tree (c->offset, gfc_index_integer_kind);
           else
             index = NULL_TREE;
+         if (index && min_index)
+           index = fold_build2_loc (input_location, PLUS_EXPR,
+                                    TREE_TYPE (index), index, min_index);
 
          if (mpz_cmp_si (c->repeat, 1) > 0)
            {

Reply via email to