https://gcc.gnu.org/g:0e92436b7ce2a247a90501d2860afd2d972ee93c

commit 0e92436b7ce2a247a90501d2860afd2d972ee93c
Author: Mikael Morin <[email protected]>
Date:   Fri Oct 16 12:26:59 2026 +0200

    Correction partielle pr109345

Diff:
---
 gcc/fortran/symbol.cc      |  2 +-
 gcc/fortran/trans-array.cc | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc
index d707752a370d..4794ae7dfcef 100644
--- a/gcc/fortran/symbol.cc
+++ b/gcc/fortran/symbol.cc
@@ -5714,7 +5714,6 @@ bool
 gfc_dummy_requires_direct_arg (gfc_symbol *sym)
 {
   return sym->attr.dummy
-        && sym->attr.target
         && !sym->attr.value
         && !sym->attr.contiguous
         && sym->ts.type != BT_ASSUMED
@@ -5726,6 +5725,7 @@ gfc_dummy_requires_direct_arg (gfc_symbol *sym)
                  || CLASS_DATA (sym)->as->type == AS_ASSUMED_RANK
                  || CLASS_DATA (sym)->as->type == AS_DEFERRED))
             || (sym->attr.dimension
+                && sym->attr.target
                 && !sym->attr.allocatable
                 && sym->as
                 && (sym->as->type == AS_ASSUMED_SHAPE
diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 62c64fbd7f90..2d33c500195f 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -725,6 +725,27 @@ gfc_get_array_span (tree desc, gfc_expr *expr)
     /* The descriptor is the _data field of a class object.  */
     tmp = class_array_element_size (TREE_OPERAND (desc, 0),
                                    UNLIMITED_POLY (expr));
+  else if (sym && sym->ts.type == BT_CLASS
+          && expr->ref->type == REF_COMPONENT
+          && expr->ref->next->type == REF_ARRAY
+          && expr->ref->next->next == NULL
+          && gfc_is_simply_contiguous (expr, false, false))
+    /* Having escaped the above, this can only be a class array dummy.  */
+    tmp = class_array_element_size (sym->backend_decl,
+                                   UNLIMITED_POLY (sym));
+  else if (sym && sym->ts.type == BT_CLASS
+          && expr->ref->type == REF_COMPONENT
+          && expr->ref->next->type == REF_ARRAY
+          && expr->ref->next->next == NULL
+          && CLASS_DATA (sym)->attr.dimension
+          && decl
+          && GFC_DECL_SAVED_DESCRIPTOR (decl))
+    {
+      /* Having escaped the above, this can only be a class array dummy.  */
+      tmp = GFC_DECL_SAVED_DESCRIPTOR (decl);
+      tmp = gfc_class_data_get (tmp);
+      tmp = gfc_conv_descriptor_span_get (tmp);
+    }
   else if (sym && sym->ts.type == BT_CLASS
           && expr->ref->type == REF_COMPONENT
           && expr->ref->next->type == REF_ARRAY

Reply via email to