public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/40882]  New: [F03] infinite recursion in gfc_get_derived_type with PPC returning derived type
@ 2009-07-27 20:06 janus at gcc dot gnu dot org
  2009-07-27 21:05 ` [Bug fortran/40882] " janus at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-07-27 20:06 UTC (permalink / raw)
  To: gcc-bugs

The following test program induces an infinite recursion in
gfc_get_derived_type:


implicit none

type :: t
  real :: data
  procedure(foo), pointer, nopass :: ppc
end type

type(t) :: o,o2

o%ppc => foo

o2 = o%ppc()

contains

  function foo()
    type(t) :: foo
    foo%data = 5.
    foo%ppc => NULL()
  end function

end


-- 
           Summary: [F03] infinite recursion in gfc_get_derived_type with
                    PPC returning derived type
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: janus at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40882


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/40882] [F03] infinite recursion in gfc_get_derived_type with PPC returning derived type
  2009-07-27 20:06 [Bug fortran/40882] New: [F03] infinite recursion in gfc_get_derived_type with PPC returning derived type janus at gcc dot gnu dot org
@ 2009-07-27 21:05 ` janus at gcc dot gnu dot org
  2009-07-28 11:41 ` janus at gcc dot gnu dot org
  2009-07-28 12:14 ` janus at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-07-27 21:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from janus at gcc dot gnu dot org  2009-07-27 21:05 -------
Here is a preliminary patch which makes the test case compile:

Index: gcc/fortran/trans-types.c
===================================================================
--- gcc/fortran/trans-types.c   (revision 150133)
+++ gcc/fortran/trans-types.c   (working copy)
@@ -1894,7 +1894,12 @@ gfc_get_ppc_type (gfc_component* c)
 {
   tree t;
   if (c->attr.function && !c->attr.dimension)
-    t = gfc_typenode_for_spec (&c->ts);
+    {
+      if (c->ts.type == BT_DERIVED)
+       t = c->ts.derived->backend_decl;
+      else
+       t = gfc_typenode_for_spec (&c->ts);
+    }
   else
     t = void_type_node;
   /* TODO: Build argument list.  */
@@ -1974,7 +1979,8 @@ gfc_get_derived_type (gfc_symbol * deriv
       if (c->ts.type != BT_DERIVED)
        continue;

-      if (!c->attr.pointer || c->ts.derived->backend_decl == NULL)
+      if ((!c->attr.pointer && !c->attr.proc_pointer)
+         || c->ts.derived->backend_decl == NULL)
        c->ts.derived->backend_decl = gfc_get_derived_type (c->ts.derived);

       if (c->ts.derived && c->ts.derived->attr.is_iso_c)
@@ -2003,10 +2009,10 @@ gfc_get_derived_type (gfc_symbol * deriv
   fieldlist = NULL_TREE;
   for (c = derived->components; c; c = c->next)
     {
-      if (c->ts.type == BT_DERIVED)
-        field_type = c->ts.derived->backend_decl;
-      else if (c->attr.proc_pointer)
+      if (c->attr.proc_pointer)
        field_type = gfc_get_ppc_type (c);
+      else if (c->ts.type == BT_DERIVED)
+        field_type = c->ts.derived->backend_decl;
       else
        {
          if (c->ts.type == BT_CHARACTER)


-- 

janus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |janus at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-07-27 21:05:09
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40882


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/40882] [F03] infinite recursion in gfc_get_derived_type with PPC returning derived type
  2009-07-27 20:06 [Bug fortran/40882] New: [F03] infinite recursion in gfc_get_derived_type with PPC returning derived type janus at gcc dot gnu dot org
  2009-07-27 21:05 ` [Bug fortran/40882] " janus at gcc dot gnu dot org
@ 2009-07-28 11:41 ` janus at gcc dot gnu dot org
  2009-07-28 12:14 ` janus at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-07-28 11:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from janus at gcc dot gnu dot org  2009-07-28 11:40 -------
Subject: Bug 40882

Author: janus
Date: Tue Jul 28 11:40:42 2009
New Revision: 150154

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150154
Log:
2009-07-28  Janus Weil  <janus@gcc.gnu.org>

        PR fortran/40882
        * trans-types.c (gfc_get_ppc_type): For derived types, directly use the
        backend_decl, instead of calling gfc_typenode_for_spec, to avoid
        infinte loop.
        (gfc_get_derived_type): Correctly handle PPCs returning derived types,
        avoiding infinite recursion.


2009-07-28  Janus Weil  <janus@gcc.gnu.org>

        PR fortran/40882
        * gfortran.dg/proc_ptr_comp_13.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/proc_ptr_comp_13.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-types.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40882


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/40882] [F03] infinite recursion in gfc_get_derived_type with PPC returning derived type
  2009-07-27 20:06 [Bug fortran/40882] New: [F03] infinite recursion in gfc_get_derived_type with PPC returning derived type janus at gcc dot gnu dot org
  2009-07-27 21:05 ` [Bug fortran/40882] " janus at gcc dot gnu dot org
  2009-07-28 11:41 ` janus at gcc dot gnu dot org
@ 2009-07-28 12:14 ` janus at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-07-28 12:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from janus at gcc dot gnu dot org  2009-07-28 12:14 -------
Fixed with r150154. Closing.


-- 

janus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40882


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-07-28 12:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-27 20:06 [Bug fortran/40882] New: [F03] infinite recursion in gfc_get_derived_type with PPC returning derived type janus at gcc dot gnu dot org
2009-07-27 21:05 ` [Bug fortran/40882] " janus at gcc dot gnu dot org
2009-07-28 11:41 ` janus at gcc dot gnu dot org
2009-07-28 12:14 ` janus at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).