This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch, Fortran, F03] PR 40870: include formal args in backend_decl of PPCs
- From: Janus Weil <janus at gcc dot gnu dot org>
- To: gfortran <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 3 Aug 2009 22:15:04 +0200
- Subject: [Patch, Fortran, F03] PR 40870: include formal args in backend_decl of PPCs
Hi all,
this small patch fixes one leftover PR related to Procedure Pointer
Components, which in their backend representation currently only get a
correct return value, but no arguments. This can lead to fake
type-conversions in PPC assignments (for an example see the PR). The
patch uses ts.interface to produce the correct backend type for PPCs.
It also takes care of possible infinite recursion loops when building
a type which contains a PPC with arguments of the original type
(generalizing the fix for PR 40882, which does the same for the return
value, committed last week).
The patch is regression-tested on x86_64-unknown-linux-gnu. Is it ok
if I commit this to trunk without an additional test case? If not, how
should the test case look like?
Cheers,
Janus
2009-08-03 Janus Weil <janus@gcc.gnu.org>
PR fortran/40870
* trans-types.c (gfc_typenode_for_spec): Prevent infinite recursion loop
if a PPC has a derived-type formal arg.
(gfc_get_ppc_type): Include formal args in backend_decl, by using the
interface symbol.
Index: gcc/fortran/trans-types.c
===================================================================
--- gcc/fortran/trans-types.c (revision 150373)
+++ gcc/fortran/trans-types.c (working copy)
@@ -1027,7 +1027,10 @@ gfc_typenode_for_spec (gfc_typespec * sp
break;
case BT_DERIVED:
- basetype = gfc_get_derived_type (spec->derived);
+ if (spec->derived->backend_decl)
+ basetype = spec->derived->backend_decl;
+ else
+ basetype = gfc_get_derived_type (spec->derived);
/* If we're dealing with either C_PTR or C_FUNPTR, we modified the
type and kind to fit a (void *) and the basetype returned was a
@@ -1895,16 +1898,14 @@ tree
gfc_get_ppc_type (gfc_component* c)
{
tree t;
+
+ if (c->ts.interface)
+ return build_pointer_type (gfc_get_function_type (c->ts.interface));
+
if (c->attr.function && !c->attr.dimension)
- {
- if (c->ts.type == BT_DERIVED)
- t = c->ts.derived->backend_decl;
- else
- t = gfc_typenode_for_spec (&c->ts);
- }
+ t = gfc_typenode_for_spec (&c->ts);
else
t = void_type_node;
- /* TODO: Build argument list. */
return build_pointer_type (build_function_type (t, NULL_TREE));
}