+2010-12-29 Janus Weil <janus@gcc.gnu.org>
+
+ PR fortran/46838
+ * expr.c (gfc_default_initializer): Handle allocatable CLASS components.
+
2010-12-29 Thomas Koenig <tkoenig@gcc.gnu.org>
* frontend-passes.c (gfc_code_walker): Handle expressions
/* See if we have a default initializer in this, but not in nested
types (otherwise we could use gfc_has_default_initializer()). */
for (comp = ts->u.derived->components; comp; comp = comp->next)
- if (comp->initializer || comp->attr.allocatable)
+ if (comp->initializer || comp->attr.allocatable
+ || (comp->ts.type == BT_CLASS && CLASS_DATA (comp)->attr.allocatable))
break;
if (!comp)
if (comp->initializer)
ctor->expr = gfc_copy_expr (comp->initializer);
- if (comp->attr.allocatable)
+ if (comp->attr.allocatable
+ || (comp->ts.type == BT_CLASS && CLASS_DATA (comp)->attr.allocatable))
{
ctor->expr = gfc_get_expr ();
ctor->expr->expr_type = EXPR_NULL;
+2010-12-29 Janus Weil <janus@gcc.gnu.org>
+
+ PR fortran/46838
+ * gfortran.dg/alloc_comp_class_2.f90: New.
+
2010-12-29 Thomas Koenig <tkoenig@gcc.gnu.org>
* gfortran.dg/character_comparison_7.f90: New test.
--- /dev/null
+! { dg-do run }
+!
+! PR 46838: [OOP] Initialization of polymorphic allocatable components
+!
+! Contributed by Salvatore Filippone <sfilippone@uniroma2.it>
+
+program bug28
+
+ implicit none
+
+ type indx_map
+ end type
+
+ type desc_type
+ integer, allocatable :: matrix_data
+ class(indx_map), allocatable :: indxmap
+ end type
+
+ type(desc_type) :: desc_a
+ call cdall(desc_a)
+
+contains
+
+ subroutine cdall(desc)
+ type(desc_type), intent(out) :: desc
+ if (allocated(desc%indxmap)) call abort()
+ end subroutine cdall
+
+end program