Janus Weil - [Patch, Fortran, F03] PR 40870: include formal args in backend_decl of (original) (raw)

This is the mail archive of the fortran@gcc.gnu.orgmailing 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 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)); }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]