https://gcc.gnu.org/g:401febfdd20bf8997cb4be5c9463745adb0d5c3d

commit 401febfdd20bf8997cb4be5c9463745adb0d5c3d
Author: Mikael Morin <[email protected]>
Date:   Thu Oct 15 12:59:54 2026 +0200

    Correction partielle optional_absent_12

Diff:
---
 gcc/fortran/symbol.cc      |  8 ++++----
 gcc/fortran/trans-array.cc |  2 +-
 gcc/fortran/trans-expr.cc  | 23 ++++++++++++++++++++++-
 3 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc
index 5adaba1e734c..d707752a370d 100644
--- a/gcc/fortran/symbol.cc
+++ b/gcc/fortran/symbol.cc
@@ -5717,20 +5717,20 @@ gfc_dummy_requires_direct_arg (gfc_symbol *sym)
         && sym->attr.target
         && !sym->attr.value
         && !sym->attr.contiguous
-        && !IS_POINTER (sym)
         && sym->ts.type != BT_ASSUMED
         && ((sym->ts.type == BT_CLASS
              && sym->ts.u.derived->attr.is_class
              && CLASS_DATA (sym)->attr.dimension
              && !CLASS_DATA (sym)->attr.allocatable
-             && CLASS_DATA (sym)->as
              && (CLASS_DATA (sym)->as->type == AS_ASSUMED_SHAPE
-                 || CLASS_DATA (sym)->as->type == AS_ASSUMED_RANK))
+                 || CLASS_DATA (sym)->as->type == AS_ASSUMED_RANK
+                 || CLASS_DATA (sym)->as->type == AS_DEFERRED))
             || (sym->attr.dimension
                 && !sym->attr.allocatable
                 && sym->as
                 && (sym->as->type == AS_ASSUMED_SHAPE
-                    || sym->as->type == AS_ASSUMED_RANK)));
+                    || sym->as->type == AS_ASSUMED_RANK
+                    || sym->as->type == AS_DEFERRED)));
 }
 
 
diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 8a6c14cf5f48..62c64fbd7f90 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -8287,7 +8287,7 @@ gfc_conv_expr_descriptor (gfc_se *se, gfc_expr *expr)
       /* A subobject of the array elements is described by a new descriptor,
         whose element type is that of the subobject and whose span is the
         element size of the array.  */
-      if (subref_array_target && !se->direct_byref
+      if (subobject_ref_target && !se->direct_byref
          && info->ref && info->ref->next)
        full = 0;
 
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 70e41a49dd99..248b4c65a3e6 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -5907,6 +5907,27 @@ class_array_fcn:
          /* present_var = present(sym); .  */
          tmp = gfc_conv_expr_present (sym);
          tmp = fold_convert (boolean_type_node, tmp);
+         if (fsym
+             && ((fsym->ts.type == BT_CLASS
+                  && fsym->ts.u.derived->attr.is_class
+                  && !CLASS_DATA (fsym)->attr.allocatable
+                  && !CLASS_DATA (fsym)->attr.class_pointer)
+                 || (!fsym->attr.allocatable
+                     && !fsym->attr.pointer))
+             && sym
+             && ((sym->ts.type == BT_CLASS
+                  && sym->ts.u.derived->attr.is_class
+                  && (CLASS_DATA (sym)->attr.allocatable
+                      || CLASS_DATA (sym)->attr.class_pointer))
+                 || sym->attr.allocatable
+                 || sym->attr.pointer))
+           {
+             tree non_null = fold_build2_loc (input_location, NE_EXPR,
+                                              boolean_type_node, pointer,
+                                              build_zero_cst (type));
+             tmp = fold_build2_loc (input_location, TRUTH_ANDIF_EXPR,
+                                    boolean_type_node, tmp, non_null);
+           }
          gfc_add_modify (&se->pre, present_var, tmp);
 
          /* else_stmt = { pointer = NULL; } .  */
@@ -8233,7 +8254,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
                  gfc_conv_subref_array_arg (&parmse, e, nodesc_arg,
                                fsym ? fsym->attr.intent : INTENT_INOUT,
                                fsym && fsym->attr.pointer, fsym, sym->name,
-                               NULL, whole_span, false,
+                               e->symtree->n.sym, whole_span, false,
                                whole_span
                                && dummy_accepts_strided_arg (fsym,
                                                              nodesc_arg));

Reply via email to