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

commit d809e70fb50435b6d95167bb026446134f7959ab
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 1bb0932d0afb..a7676090f710 100644
--- a/gcc/fortran/class.cc
+++ b/gcc/fortran/class.cc
@@ -1624,7 +1624,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();
@@ -2129,8 +2128,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 fcec74c7fd06..9694935c6ef9 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -7584,7 +7584,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
@@ -7629,7 +7632,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