Bug 40870

Summary: [F03] include formal args in backend_decl of PPCs
Product: gcc Reporter: janus
Component: fortranAssignee: janus
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs
Priority: P3 Keywords: wrong-code
Version: 4.5.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2009-08-03 20:17:20

Description janus 2009-07-27 08:11:49 UTC
Another PPC leftover item, cf. trans-types.c (gfc_get_ppc_type): When translating the Fortran frontend structures to a backend tree, the argument list of procedure pointer components is currently not being used.

This becomes visible in a test case like this:


implicit none
procedure(foo), pointer :: pp
type :: t
  procedure(foo), pointer, nopass :: ppc
end type
type(t)::o

pp => foo
o%ppc => foo
pp => o%ppc

contains

  integer function foo(a,b)
    integer, intent(in) :: a,b
    foo = a + b
  end function

end


Compiling with -fdump-tree-original shows the following code for the three pointer assignments:

  pp = foo;
  o.ppc = (integer(kind=4) (*<T3c6>) (void)) foo;
  pp = (integer(kind=4) (*<T3c8>) (integer(kind=4) &, integer(kind=4) &)) o.ppc;

The first one is ok, but the last two involve type casting, although they have exactly the same interface (simply because the arguments of the PPC are missing).
Comment 1 janus 2009-08-18 14:23:54 UTC
Subject: Bug 40870

Author: janus
Date: Tue Aug 18 14:23:35 2009
New Revision: 150875

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150875
Log:
2009-08-18  Janus Weil  <janus@gcc.gnu.org>
	    Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/40870
	* trans-types.c (gfc_get_ppc_type): Include formal args in backend_decl
	using the interface symbol. Character types are returned by reference.
	(gfc_get_derived_type): Prevent infinite recursion loop
	if a PPC has a derived-type formal arg.

2009-08-18  Janus Weil  <janus@gcc.gnu.org>
	    Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/40870
	* gfortran.dg/proc_ptr_comp_13.f90: Extended.


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

Comment 2 janus 2009-08-18 14:25:00 UTC
Fixed with r150875. Closing.