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"

Reply via email to