This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi all, this is fixing a small problem with procedure pointer components returning a derived type. If the result type is the same as the type which contains the PPC, gfc_get_derived_type would enter an infinite recursion loop. The patch handles this case in a similar fashion as for pointer components, i.e. first making sure all the backend_decl's of derived types are there, and then using those backend_decl's instead of recursing to gfc_get_derived_type. Regtested on x86_64-unknown-linux-gnu. Ok for trunk? Cheers, Janus 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.
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)
Attachment:
proc_ptr_comp_13.f90
Description: Binary data
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |