[gcc(refs/users/mikael/heads/refactor_descriptor_v08)] Correction régression select_type_26

Mikael Morin mikael@gcc.gnu.org
Tue Sep 23 14:20:03 GMT 2025


https://gcc.gnu.org/g:30031fee7b03249e09973209f7ede9bc847461aa

commit 30031fee7b03249e09973209f7ede9bc847461aa
Author: Mikael Morin <mikael@gcc.gnu.org>
Date:   Tue Sep 23 16:18:42 2025 +0200

    Correction régression select_type_26

Diff:
---
 gcc/fortran/trans-array.cc | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index b735e3a35f2b..cea098c5a94e 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -3810,8 +3810,31 @@ classify_array_ref (tree array, tree ref_base, gfc_expr *expr,
 	  && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (array))))
     return ARS_SPANNED_PTR_ARITH;
 
-  if (!(ar && ar->type == AR_ELEMENT)
-      && is_class_array_ref (ref_base, expr, nullptr))
+  if (ar && ar->type == AR_ELEMENT)
+    {
+      tree cdesc;
+      /* For class arrays the class declaration is stored in the saved
+	 descriptor.  */
+      if (INDIRECT_REF_P (array)
+	  && DECL_LANG_SPECIFIC (TREE_OPERAND (array, 0))
+	  && GFC_DECL_SAVED_DESCRIPTOR (TREE_OPERAND (array, 0)))
+	cdesc = gfc_class_data_get (GFC_DECL_SAVED_DESCRIPTOR (
+				      TREE_OPERAND (array, 0)));
+      else
+	cdesc = array;
+
+      /* Class container types do not always have the GFC_CLASS_TYPE_P
+	 but the canonical type does.  */
+      if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (cdesc))
+	  && TREE_CODE (cdesc) == COMPONENT_REF)
+	{
+	  tree type = TREE_TYPE (TREE_OPERAND (cdesc, 0));
+	  if (TYPE_CANONICAL (type)
+	      && GFC_CLASS_TYPE_P (TYPE_CANONICAL (type)))
+	    return ARS_CLASS_PTR_ARITH;
+	}
+    }
+  else if (is_class_array_ref (ref_base, expr, nullptr))
     return ARS_CLASS_PTR_ARITH;
 
   if (tmp_array || non_negative_strides_array_p (array))


More information about the Gcc-cvs mailing list