]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorPaul Thomas <pault@gcc.gnu.org>
Wed, 12 Oct 2005 20:41:28 +0000 (20:41 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Wed, 12 Oct 2005 20:41:28 +0000 (20:41 +0000)
2005-10-12  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/24092
* trans-types.c (gfc_get_derived_type): Insert code to obtain backend
declaration for derived types, building if necessary.  Return the
derived type if the fields have been built by this process.  Otherwise,
continue as before but using the already obtained backend_decls for the
derived type components.  Change the gcc_assert to act on the field.

2005-10-10  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/24092
* gfortran.dg/derived_pointer_recursion.f90: New test.

From-SVN: r105331

gcc/fortran/ChangeLog
gcc/fortran/trans-types.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/derived_pointer_recursion.f90 [new file with mode: 0755]

index 94e2418acf6979dcd62ebd65ffe820993395c5ee..86aeeae89ec2630ed28a7bd4884cbb6e03404784 100644 (file)
@@ -1,3 +1,12 @@
+2005-10-12  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/24092
+       * trans-types.c (gfc_get_derived_type): Insert code to obtain backend
+       declaration for derived types, building if necessary.  Return the
+       derived type if the fields have been built by this process.  Otherwise,
+       continue as before but using the already obtained backend_decls for the
+       derived type components.  Change the gcc_assert to act on the field.
+
 2005-10-12  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/18082
index e16db8836a99cc8de2b1d28e6ffa85d3e3924655..81a90f1d373f7d1baca08aec0ced4e21a019f34d 100644 (file)
@@ -1415,21 +1415,30 @@ gfc_get_derived_type (gfc_symbol * derived)
       derived->backend_decl = typenode;
     }
 
+  /* Go through the derived type components, building them as
+     necessary. The reason for doing this now is that it is
+     possible to recurse back to this derived type through a
+     pointer component (PR24092). If this happens, the fields
+     will be built and so we can return the type.  */
+  for (c = derived->components; c; c = c->next)
+    {
+      if (c->ts.type != BT_DERIVED)
+       continue;
+
+      if (!c->pointer || c->ts.derived->backend_decl == NULL)
+       c->ts.derived->backend_decl = gfc_get_derived_type (c->ts.derived);
+    }
+
+  if (TYPE_FIELDS (derived->backend_decl))
+    return derived->backend_decl;
+
   /* Build the type member list. Install the newly created RECORD_TYPE
      node as DECL_CONTEXT of each FIELD_DECL.  */
   fieldlist = NULL_TREE;
   for (c = derived->components; c; c = c->next)
     {
-      if (c->ts.type == BT_DERIVED && c->pointer)
-        {
-          if (c->ts.derived->backend_decl)
-           /* We already saw this derived type so use the exiting type.
-              It doesn't matter if it is incomplete.  */
-           field_type = c->ts.derived->backend_decl;
-          else
-           /* Recurse into the type.  */
-           field_type = gfc_get_derived_type (c->ts.derived);
-        }
+      if (c->ts.type == BT_DERIVED)
+        field_type = c->ts.derived->backend_decl;
       else
        {
          if (c->ts.type == BT_CHARACTER)
@@ -1464,8 +1473,9 @@ gfc_get_derived_type (gfc_symbol * derived)
 
       DECL_PACKED (field) |= TYPE_PACKED (typenode);
 
-      gcc_assert (!c->backend_decl);
-      c->backend_decl = field;
+      gcc_assert (field);
+      if (!c->backend_decl)
+       c->backend_decl = field;
     }
 
   /* Now we have the final fieldlist.  Record it, then lay out the
index be34d210880a99eb59a1758b9b55aa8d91c205f8..99d2dbd33099717330947e70ddc9cdeb0ea44f66 100644 (file)
@@ -1,3 +1,8 @@
+2005-10-10  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/24092
+       * gfortran.dg/derived_pointer_recursion.f90: New test.
+
 2005-10-12  Adrian Straetling <straetling@de.ibm.com>
 
        * gcc.c-torture/execute/20051012-1.c: New test.
 2005-10-12  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/18082
-       gfortran.dg/automatic_char_len_1.f90: New test.
+       gfortran.dg/automatic_char_len_1.f90: New test.
 
 2005-10-12  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/20847
-       gfortran.dg/save_common.f90: New test.
+       gfortran.dg/save_common.f90: New test.
 
        PR fortran/20856
-       gfortran.dg/save_result.f90: New test.
+       gfortran.dg/save_result.f90: New test.
 
 2005-10-12  Nathan Sidwell  <nathan@codesourcery.com>
 
@@ -50,7 +55,7 @@
 2005-10-12  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/24207
-       gfortran.dg/private_type_3.f90: New test.
+       gfortran.dg/private_type_3.f90: New test.
 
 2005-10-11  Steven G. Kargl  <kargls@comcast.net>
 
diff --git a/gcc/testsuite/gfortran.dg/derived_pointer_recursion.f90 b/gcc/testsuite/gfortran.dg/derived_pointer_recursion.f90
new file mode 100755 (executable)
index 0000000..5ae5325
--- /dev/null
@@ -0,0 +1,22 @@
+! { dg-do compile }
+! { dg-options "-O0" }
+!  Tests patch for PR24092 - This would ICE because of the loop in the
+!  derived type definitions.
+!
+   module llo
+      type :: it
+         character*10  :: k
+         integer :: c(2)
+      end type it
+      type :: bt
+         type (nt), pointer :: p
+      end type bt
+      type :: nt
+         type (it) :: i
+         type (bt) :: b
+      end type nt
+      type (bt), pointer :: ptr
+   end module llo
+!  copyright 1996 Loren P. Meissner -- May be distributed if this line is included.
+!  Linked List operations with Pointer to Pointer
+