From fbd30c381c53eb734642603671fadfa9120afecd Mon Sep 17 00:00:00 2001 From: Janus Weil Date: Wed, 29 Dec 2010 17:14:11 +0100 Subject: re PR fortran/46838 ([OOP] Initialization of polymorphic allocatable components) 2010-12-29 Janus Weil PR fortran/46838 * expr.c (gfc_default_initializer): Handle allocatable CLASS components. 2010-12-29 Janus Weil PR fortran/46838 * gfortran.dg/alloc_comp_class_2.f90: New. From-SVN: r168322 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/expr.c | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 8fc74f8..759db83 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2010-12-29 Janus Weil + + PR fortran/46838 + * expr.c (gfc_default_initializer): Handle allocatable CLASS components. + 2010-12-29 Thomas Koenig * frontend-passes.c (gfc_code_walker): Handle expressions diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index a22e660..a222ff2 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -3648,7 +3648,8 @@ gfc_default_initializer (gfc_typespec *ts) /* 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) @@ -3665,7 +3666,8 @@ gfc_default_initializer (gfc_typespec *ts) 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; -- cgit v1.1