Hi All, This is a regression caused by my patch for PR109345 - r15-5083.
I overlooked the possibility that the unlimited polymorphic container might be the component of a dummy derived type. The fix is simple and relatively obvious. Regards Paul Fortran: Fix regression caused by r15-5083 [PR117797] 2024-12-01 Paul Thomas <pa...@gcc.gnu.org> gcc/fortran PR fortran/117797 * trans-array.cc (gfc_get_array_span): Prevent unlimited poly- morphic dummy variable expressions, if the array is a component of a derived type, from using GFC_DECL_SAVED_DESCRIPTOR for the class container. Use a gcc_assert to verify the presence of the GFC_DECL_SAVED_DESCRIPTOR. gcc/testsuite/ PR fortran/117797 * gfortran.dg/pr117797.f90 : New test.
diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index a458af322ce..b874d5bbfa9 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -991,9 +991,11 @@ gfc_get_array_span (tree desc, gfc_expr *expr) the element size need not be the same as the span. Obtain the class container, which is simplified here by there being no component references. */ - if (sym && sym->attr.dummy) + if (sym && sym->attr.dummy && TREE_CODE (desc) != COMPONENT_REF) { tmp = gfc_get_symbol_decl (sym); + gcc_assert (DECL_LANG_SPECIFIC (tmp) + && GFC_DECL_SAVED_DESCRIPTOR (tmp)); tmp = GFC_DECL_SAVED_DESCRIPTOR (tmp); if (INDIRECT_REF_P (tmp)) tmp = TREE_OPERAND (tmp, 0);