https://gcc.gnu.org/g:fc8f8ce0d8601c4b8358dc2f7f421c0138c9be07
commit fc8f8ce0d8601c4b8358dc2f7f421c0138c9be07 Author: Mikael Morin <mik...@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 83e314454f1b..9a55ddcb6c1b 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))