CLASS_DATA (fsym)->attr.class_pointer
|| CLASS_DATA (fsym)->attr.allocatable);
- if (fsym && (fsym->ts.type == BT_DERIVED
- || fsym->ts.type == BT_ASSUMED)
- && e->ts.type == BT_CLASS
- && !CLASS_DATA (e)->attr.dimension
- && !CLASS_DATA (e)->attr.codimension)
- parmse.expr = gfc_class_data_get (parmse.expr);
-
/* If an ALLOCATABLE dummy argument has INTENT(OUT) and is
allocated on entry, it must be deallocated. */
if (fsym && fsym->attr.intent == INTENT_OUT
if (fsym->ts.type == BT_CLASS)
{
gfc_symbol *vtab;
- gcc_assert (fsym->ts.u.derived == e->ts.u.derived);
vtab = gfc_find_derived_vtab (fsym->ts.u.derived);
tmp = gfc_get_symbol_decl (vtab);
tmp = gfc_build_addr_expr (NULL_TREE, tmp);
gfc_add_expr_to_block (&se->pre, tmp);
}
+ if (fsym && (fsym->ts.type == BT_DERIVED
+ || fsym->ts.type == BT_ASSUMED)
+ && e->ts.type == BT_CLASS
+ && !CLASS_DATA (e)->attr.dimension
+ && !CLASS_DATA (e)->attr.codimension)
+ parmse.expr = gfc_class_data_get (parmse.expr);
+
/* Wrap scalar variable in a descriptor. We need to convert
the address of a pointer back to the pointer itself before,
we can assign it to the data field. */
--- /dev/null
+! { dg-do compile }
+!
+! PR 55037: [4.8 Regression] [OOP] ICE with local allocatable variable of abstract type
+!
+! Contributed by <mrestelli@gmail.com>
+
+module m1
+ implicit none
+ type, abstract :: c_stv
+ contains
+ procedure, pass(x) :: source
+ end type c_stv
+contains
+ pure subroutine source(y,x)
+ class(c_stv), intent(in) :: x
+ class(c_stv), allocatable, intent(out) :: y
+ end subroutine source
+end module m1
+
+module m2
+ use m1, only : c_stv
+ implicit none
+contains
+ subroutine sub(u0)
+ class(c_stv), intent(inout) :: u0
+ class(c_stv), allocatable :: tmp
+ call u0%source(tmp)
+ end subroutine sub
+end module m2
+
+
+program p
+ implicit none
+ type :: c_stv
+ end type
+ class(c_stv), allocatable :: tmp
+ call source(tmp)
+contains
+ subroutine source(y)
+ type(c_stv), allocatable, intent(out) :: y
+ end subroutine
+end
+
+! { dg-final { cleanup-modules "m1 m2" } }