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

commit ddfaa8774bb0fcd57d91a84ec1377a4d3a123f37
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Fri Apr 18 19:11:01 2025 +0200

    Correction régression nested_array_constructor_6

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

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index ee329b82926e..d0a205fef90b 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -2834,6 +2834,33 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, 
bool subscript,
              gfc_add_block_to_block (&outer_loop->post, &se.post);
            }
          trans_array_constructor (ss, where);
+         {
+           gcc_assert (info->shape != nullptr || ss->dimen == 1);
+           tree type = gfc_typenode_for_spec (&ss_info->expr->ts);
+           if (ss_info->expr->ts.type == BT_CHARACTER
+               && ss_info->expr->ts.u.cl->length
+               && ss_info->expr->ts.u.cl->length->expr_type == EXPR_CONSTANT)
+             type = build_pointer_type (type);
+           tree spacing = TYPE_SIZE_UNIT (type);
+           if (spacing == NULL_TREE)
+             spacing = ss_info->expr->ts.u.cl->backend_decl;
+           spacing = fold_convert_loc (input_location, gfc_array_index_type,
+                                       spacing);
+           for (n = 0; n < ss->dimen; n++)
+             {
+               int dim = ss->dim[n];
+
+               info->spacing[dim] = spacing;
+               if (n < ss->dimen - 1)
+                 {
+                   tree extent = gfc_conv_mpz_to_tree_type (info->shape[n],
+                                                   gfc_array_index_type);
+                   spacing = fold_build2_loc (input_location, MULT_EXPR,
+                                              gfc_array_index_type, spacing,
+                                              extent);
+                 }
+             }
+         }
          break;
 
         case GFC_SS_TEMP:
@@ -4574,6 +4601,7 @@ done:
 
          /* FALLTHRU */
        case GFC_SS_FUNCTION:
+       case GFC_SS_CONSTRUCTOR:
          for (n = 0; n < ss->dimen; n++)
            {
              int dim = ss->dim[n];
@@ -4585,37 +4613,6 @@ done:
            }
          break;
 
-       case GFC_SS_CONSTRUCTOR:
-         {
-           gcc_assert (info->shape != nullptr || ss->dimen == 1);
-           tree type = gfc_typenode_for_spec (&ss_info->expr->ts);
-           if (ss_info->expr->ts.type == BT_CHARACTER
-               && ss_info->expr->ts.u.cl->length
-               && ss_info->expr->ts.u.cl->length->expr_type == EXPR_CONSTANT)
-             type = build_pointer_type (type);
-           tree spacing = fold_convert_loc (input_location,
-                                            gfc_array_index_type,
-                                            TYPE_SIZE_UNIT (type));
-           for (n = 0; n < ss->dimen; n++)
-             {
-               int dim = ss->dim[n];
-
-               info->start[dim]  = gfc_index_zero_node;
-               info->end[dim]    = gfc_index_zero_node;
-               info->stride[dim] = gfc_index_one_node;
-               info->spacing[dim] = spacing;
-               if (n < ss->dimen - 1)
-                 {
-                   tree extent = gfc_conv_mpz_to_tree_type (info->shape[n],
-                                                   gfc_array_index_type);
-                   spacing = fold_build2_loc (input_location, MULT_EXPR,
-                                              gfc_array_index_type, spacing,
-                                              extent);
-                 }
-             }
-         }
-         break;
-
        default:
          break;
        }

Reply via email to