re PR fortran/30660 (Allocatable components of a derived type "require" the SAVE...
authorPaul Thomas <pault@gcc.gnu.org>
Fri, 23 Feb 2007 16:35:25 +0000 (16:35 +0000)
committerTobias Burnus <burnus@gcc.gnu.org>
Fri, 23 Feb 2007 16:35:25 +0000 (17:35 +0100)
2007-02-23  Paul Thomas <pault@gcc.gnu.org>

        PR fortran/30660
        * resolve.c (has_default_initializer): New function.
        (resolve_fl_variable): Call has_default_initializer to determine if
        the derived type has a default initializer to its ultimate
        components.

2007-02-23  Paul Thomas <pault@gcc.gnu.org>

        PR fortran/30660
        * gfortran.dg/alloc_comp_basics_4.f90: Add component with an
        allocatable component.

From-SVN: r122263

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/alloc_comp_basics_4.f90

index ce305532ed80faabadf1f1fd6ef31ba5befc3d5c..777f926421b435082a645a73dc5409904793f0ca 100644 (file)
@@ -1,3 +1,12 @@
+2007-02-23  Paul Thomas <pault@gcc.gnu.org>
+
+       PR fortran/30660
+       * resolve.c (has_default_initializer): New function.
+       (resolve_fl_variable): Call has_default_initializer to determine if
+       the derived type has a default initializer to its ultimate
+       components.
+
+
 2007-02-22  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        * options.c (set_default_std_flags): New function to consolidate
index 8db36b5f2c0e1321736c7809c11824fe33a2d065..a66d1ae98070855c7b0b9fec32eac0dedf3f5fbc 100644 (file)
@@ -5529,6 +5529,21 @@ resolve_fl_var_and_proc (gfc_symbol *sym, int mp_flag)
 }
 
 
+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
@@ -5676,9 +5691,7 @@ resolve_fl_variable (gfc_symbol *sym, int mp_flag)
      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;
+    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
index cce1dd9897a849bda9a13611666b0e83e7826e0c..45bed9f21a633d58a141579910ed7e95c355252b 100644 (file)
@@ -1,3 +1,10 @@
+2007-02-23  Paul Thomas <pault@gcc.gnu.org>
+
+       PR fortran/30660
+       * gfortran.dg/alloc_comp_basics_4.f90: Add component with an
+       allocatable component.
+
+
 2007-02-23  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * gcc.dg/torture/builtin-logb-1.c: New test.
index c910b708bd3f2f405ea58b4d8ec3024d44b6c0e2..508d5670689f03243310a51a73f23e9be5fabe54 100644 (file)
@@ -6,8 +6,14 @@
 ! Contributed by Toon Moene <toon@moene.indiv.nluug.nl>
 !
 MODULE types_m
+  TYPE coord_t
+    INTEGER ncord
+    REAL,ALLOCATABLE,DIMENSION(:) :: x, y
+  END TYPE
+
   TYPE grib_t
     REAL,DIMENSION(:),ALLOCATABLE :: vdata
+   TYPE(coord_t) coords
   END TYPE
 END MODULE