[Bug fortran/30660] [4.2 and 4.1 only] Allocatable components of a derived type "require" the SAVE attribute.
pault at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Sat Feb 17 22:42:00 GMT 2007
------- Comment #8 from pault at gcc dot gnu dot org 2007-02-17 22:42 -------
This works and regtests OK:
Index: gcc/fortran/resolve.c
===================================================================
*** gcc/fortran/resolve.c (revision 121864)
--- gcc/fortran/resolve.c (working copy)
*************** resolve_fl_var_and_proc (gfc_symbol *sym
*** 5529,5534 ****
--- 5529,5549 ----
}
+ static gfc_component *
+ has_default_initializer (gfc_symbol *der)
+ {
+ gfc_component *c;
+ for (c = der->components; c; c = c->next)
+ if ((c->ts.type != BT_DERIVED && c->initializer)
+ || (c->ts.type == BT_DERIVED
+ && !c->pointer
+ && has_default_initializer (c->ts.derived)))
+ break;
+
+ return c;
+ }
+
+
/* Resolve symbols with flavor variable. */
static try
*************** resolve_fl_variable (gfc_symbol *sym, in
*** 5676,5684 ****
components. */
c = NULL;
if (sym->ts.type == BT_DERIVED && !(sym->value || flag))
! for (c = sym->ts.derived->components; c; c = c->next)
! if (c->initializer)
! break;
/* 4th constraint in section 11.3: "If an object of a type for which
component-initialization is specified (R429) appears in the
--- 5691,5697 ----
components. */
c = NULL;
if (sym->ts.type == BT_DERIVED && !(sym->value || flag))
! c = has_default_initializer (sym->ts.derived);
/* 4th constraint in section 11.3: "If an object of a type for which
component-initialization is specified (R429) appears in the
I need to think about it - it looks a bit clumsy to me and I need also to think
through compliance with the standard.
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30660
More information about the Gcc-bugs
mailing list