Janus Weil - Re: [Patch, Fortran, F03] PR 40870: include formal args in backend_dec (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] |
Re: [Patch, Fortran, F03] PR 40870: include formal args in backend_decl of PPCs
- From: Janus Weil
- To: Tobias Burnus
- Cc: Paul Richard Thomas , gfortran , gcc-patches
- Date: Tue, 18 Aug 2009 14:11:21 +0200
- Subject: Re: [Patch, Fortran, F03] PR 40870: include formal args in backend_decl of PPCs
- References: <854832d40908031315t50eee9a5sff87f1505aced93c@mail.gmail.com> <339c37f20908040228k538c6ec2qca9c1a2dc13c5de@mail.gmail.com> <854832d40908040502n5a0b8071kab9a5bd14bd71a3f@mail.gmail.com> <339c37f20908040543m1a36b348nee4d387287d70808@mail.gmail.com> <854832d40908040617x2bad3387q96c5a6595f55f787@mail.gmail.com> <339c37f20908040723p2b2dae7eq6b4b302c16d30e63@mail.gmail.com> <854832d40908050150u7f088d85ja82c9f05aaab5d03@mail.gmail.com> <4A8A5502.50800@net-b.de> <854832d40908180509t194bfci7f16ea9e3b9eb15b@mail.gmail.com>
My suggestion would be to commit the patch as attached,
here ...
Index: gcc/testsuite/gfortran.dg/proc_ptr_comp_13.f90
--- gcc/testsuite/gfortran.dg/proc_ptr_comp_13.f90 (revision 150822) +++ gcc/testsuite/gfortran.dg/proc_ptr_comp_13.f90 (working copy) @@ -1,6 +1,7 @@ ! { dg-do run } ! -! PR 40882: [F03] infinite recursion in gfc_get_derived_type with PPC returning derived type +! PR 40882: [F03] infinite recursion in gfc_get_derived_type with PPC returning derived type. +! At the same time, check that a formal argument does not cause infinite recursion (PR 40870). ! ! Contributed by Janus Weil janus@gcc.gnu.org @@ -9,6 +10,7 @@ implicit none type :: t integer :: data procedure(foo), pointer, nopass :: ppc + procedure(type(t)), pointer, nopass :: ppc2 end type type(t) :: o,o2 @@ -16,7 +18,7 @@ type(t) :: o,o2 o%data = 1 o%ppc => foo -o2 = o%ppc() +o2 = o%ppc(o) if (o%data /= 1) call abort() if (o2%data /= 5) call abort() @@ -25,9 +27,9 @@ if (associated(o2%ppc)) call abort() contains - function foo() - type(t) :: foo - foo%data = 5 + function foo(arg) + type(t) :: foo, arg + foo%data = arg%data * 5 foo%ppc => NULL() end function Index: gcc/fortran/trans-types.c
--- gcc/fortran/trans-types.c (revision 150822) +++ gcc/fortran/trans-types.c (working copy) @@ -1895,16 +1895,18 @@ tree gfc_get_ppc_type (gfc_component* c) { tree t;
- if (c->attr.function && !c->attr.dimension)
- {
if (c->ts.type == BT_DERIVED)
- t = c->ts.u.derived->backend_decl;
else
- t = gfc_typenode_for_spec (&c->ts);
- }
- /* Explicit interface. */
- if (c->attr.if_source != IFSRC_UNKNOWN && c->ts.interface)
- return build_pointer_type (gfc_get_function_type (c->ts.interface));
- /* Implicit interface (only return value may be known). */
- if (c->attr.function && !c->attr.dimension
&& !(c->ts.type == BT_CHARACTER && !c->attr.is_bind_c))
- 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)); }
@@ -2012,8 +2014,11 @@ gfc_get_derived_type (gfc_symbol * deriv components' backend_decl may have not been built. */ if (derived->backend_decl) {
/* Its components' backend_decl have been built. */
if (TYPE_FIELDS (derived->backend_decl))
/* Its components' backend_decl have been built or we are
seeing recursion through the formal arglist of a procedure
pointer component. */
if (TYPE_FIELDS (derived->backend_decl)
|| derived->attr.proc_pointer_comp) return derived->backend_decl; else typenode = derived->backend_decl;
- References:
- [Patch, Fortran, F03] PR 40870: include formal args in backend_decl of PPCs
* From: Janus Weil - Re: [Patch, Fortran, F03] PR 40870: include formal args in backend_decl of PPCs
* From: Paul Richard Thomas - Re: [Patch, Fortran, F03] PR 40870: include formal args in backend_decl of PPCs
* From: Janus Weil - Re: [Patch, Fortran, F03] PR 40870: include formal args in backend_decl of PPCs
* From: Paul Richard Thomas - Re: [Patch, Fortran, F03] PR 40870: include formal args in backend_decl of PPCs
* From: Janus Weil - Re: [Patch, Fortran, F03] PR 40870: include formal args in backend_decl of PPCs
* From: Paul Richard Thomas - Re: [Patch, Fortran, F03] PR 40870: include formal args in backend_decl of PPCs
* From: Janus Weil - Re: [Patch, Fortran, F03] PR 40870: include formal args in backend_decl of PPCs
* From: Tobias Burnus - Re: [Patch, Fortran, F03] PR 40870: include formal args in backend_decl of PPCs
* From: Janus Weil
- [Patch, Fortran, F03] PR 40870: include formal args in backend_decl of PPCs
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |