[Bug fortran/60357] [F08] structure constructor with unspecified values for allocatable components
janus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Feb 27 22:19:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60357
--- Comment #2 from janus at gcc dot gnu.org ---
Draft patch:
Index: gcc/fortran/array.c
===================================================================
--- gcc/fortran/array.c (revision 208207)
+++ gcc/fortran/array.c (working copy)
@@ -1307,6 +1307,9 @@ check_constructor (gfc_constructor_base ctor, bool
for (c = gfc_constructor_first (ctor); c; c = gfc_constructor_next (c))
{
e = c->expr;
+
+ if (!e)
+ continue;
if (e->expr_type != EXPR_ARRAY)
{
Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c (revision 208207)
+++ gcc/fortran/expr.c (working copy)
@@ -2200,7 +2200,7 @@ check_alloc_comp_init (gfc_expr *e)
ctor = gfc_constructor_first (e->value.constructor);
comp; comp = comp->next, ctor = gfc_constructor_next (ctor))
{
- if (comp->attr.allocatable
+ if (comp->attr.allocatable && ctor->expr
&& ctor->expr->expr_type != EXPR_NULL)
{
gfc_error("Invalid initialization expression for ALLOCATABLE "
Index: gcc/fortran/primary.c
===================================================================
--- gcc/fortran/primary.c (revision 208207)
+++ gcc/fortran/primary.c (working copy)
@@ -2365,6 +2365,13 @@ build_actual_constructor (gfc_structure_ctor_compo
return false;
value = gfc_copy_expr (comp->initializer);
}
+ else if (comp->attr.allocatable)
+ {
+ if (!gfc_notify_std (GFC_STD_F2008, "No initializer for "
+ "allocatable component '%s' given in the structure "
+ "constructor at %C", comp->name))
+ return false;
+ }
else
{
gfc_error ("No initializer for component '%s' given in the"
More information about the Gcc-bugs
mailing list