|| GFC_ARRAY_TYPE_P (TREE_TYPE (se.expr)));
gcc_assert (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (sym->backend_decl)));
+ if (sym->ts.type == BT_CHARACTER)
+ {
+ /* Emit a DECL_EXPR for the variable sized array type in so the
+ gimplification of its type sizes works correctly. */
+ tree arraytype;
+ tmp = TREE_TYPE (sym->backend_decl);
+ arraytype = TREE_TYPE (GFC_TYPE_ARRAY_DATAPTR_TYPE (tmp));
+ if (! TYPE_NAME (arraytype))
+ TYPE_NAME (arraytype) = build_decl (UNKNOWN_LOCATION, TYPE_DECL,
+ NULL_TREE, arraytype);
+ gfc_add_expr_to_block (&se.pre, build1 (DECL_EXPR,
+ arraytype, TYPE_NAME (arraytype)));
+ }
+
if (GFC_ARRAY_TYPE_P (TREE_TYPE (se.expr)))
{
if (INDIRECT_REF_P (se.expr))
--- /dev/null
+! { dg-do compile }
+! { dg-options "-O3" }
+!
+! Test the fix for pr117901, in which the variable length character in
+! the SELECT TYPE construct caused an ICE in make_ssa_name_fn. This is
+! a much reduced testcase, extracted from class_transformational_1.f90.
+! Note that it does not have references to transformational functions
+! of class objects!
+!
+Module class_tests
+contains
+ subroutine class_rebar (arg)
+ class(*), allocatable :: arg(:)
+ call class_bar (arg)
+ end
+ subroutine class_bar(x)
+ class(*), intent(in) :: x(..)
+ integer :: checksum
+ select rank (x)
+ rank (1)
+ select type (x)
+ type is (character(*))
+ checksum = sum(ichar(x(:)(1:1)) + ichar(x(:)(2:2)))
+ print *, checksum
+ end select
+ rank (2)
+ rank (3)
+ end select
+ end
+end module class_tests