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

commit acc34b33d1968cd74927f63a0103a07e5c980c8a
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Mon May 26 16:32:36 2025 +0200

    Sauvegarde code finalization

Diff:
---
 gcc/fortran/class.cc      | 10 ++++++++--
 gcc/fortran/trans-expr.cc |  9 +++++++--
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/gcc/fortran/class.cc b/gcc/fortran/class.cc
index f9a2c96f77d8..e6a99be93210 100644
--- a/gcc/fortran/class.cc
+++ b/gcc/fortran/class.cc
@@ -1622,7 +1622,6 @@ generate_finalization_wrapper (gfc_symbol *derived, 
gfc_namespace *ns,
   array->ts.u.derived = derived;
   array->attr.flavor = FL_VARIABLE;
   array->attr.dummy = 1;
-  array->attr.contiguous = 1;
   array->attr.dimension = 1;
   array->attr.artificial = 1;
   array->as = gfc_get_array_spec();
@@ -2125,8 +2124,15 @@ finish_assumed_rank:
       last_code->symtree = ancestor_wrapper->symtree;
       last_code->resolved_sym = ancestor_wrapper->symtree->n.sym;
 
+      gfc_expr *parent_type_array = gfc_lval_expr_from_sym (array);
+      gfc_ref **subref = &parent_type_array->ref;
+      if (*subref)
+       subref = &(*subref)->next;
+      insert_component_ref (&parent_type_array->ts, subref,
+                           derived->components->name);
+
       last_code->ext.actual = gfc_get_actual_arglist ();
-      last_code->ext.actual->expr = gfc_lval_expr_from_sym (array);
+      last_code->ext.actual->expr = parent_type_array;
       last_code->ext.actual->next = gfc_get_actual_arglist ();
       last_code->ext.actual->next->expr = gfc_lval_expr_from_sym (byte_stride);
       last_code->ext.actual->next->next = gfc_get_actual_arglist ();
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 9845f7fe71d6..bd3f35245050 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -7546,7 +7546,10 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 
              else if (e->expr_type == EXPR_VARIABLE
                    && is_subref_array (e)
-                   && !(fsym && fsym->attr.pointer))
+                   && !(fsym && fsym->attr.pointer)
+                   && !(e->symtree->n.sym
+                        && e->symtree->n.sym->as
+                        && e->symtree->n.sym->as->type == AS_ASSUMED_RANK))
                /* The actual argument is a component reference to an
                   array of derived types.  In this case, the argument
                   is converted to a temporary, which is passed and then
@@ -7591,7 +7594,9 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
                       && (fsym->attr.target
                           ? gfc_is_not_contiguous (e)
                           : !gfc_is_simply_contiguous (e, false, true))
-                      && gfc_expr_is_variable (e))
+                      && gfc_expr_is_variable (e)
+                      && !(e->symtree->n.sym->as
+                           && e->symtree->n.sym->as->type == AS_ASSUMED_RANK))
                {
                  gfc_conv_subref_array_arg (&parmse, e, nodesc_arg,
                                             fsym->attr.intent,

Reply via email to