Procedure Pointer Components

Janus Weil jaydub66@googlemail.com
Mon Sep 1 20:47:00 GMT 2008


2008/8/31 Daniel Kraft <d@domob.eu>:
> However, what's about doing a mixture, e.g. keep the gfc_component with
> attr->proc_ptr but add a new pointer member pointing to a gfc_symtree* in
> the f2k_derived namespace to use for whatever this is advantageous? But you
> probably intended to do it like this anyways ;)  At least I could imagine
> this.

That's exactly what I intended to do.

Here's a new incarnation of my patch, which at this point is able to
compile a simple test program like this:


type :: t
  procedure(), pointer, nopass :: ppc
end type

type(t) :: obj

obj%ppc => sub

call obj%ppc()

contains

  subroutine sub
    print *,"sub"
  end subroutine

end


The dump for this looks pretty much like what one gets from an
equivalent C program:

MAIN__ ()
{
  struct t obj;
  static integer(kind=4) options.1[8] = {68, 255, 0, 0, 0, 1, 0, 1};
  static void sub (void);

  _gfortran_set_options (8, (void *) &options.1);
  obj.ppc = sub;
  ppc ();
}


The only problem is that at linking time one gets

test1.f90:(.text+0x8f): undefined reference to `ppc_'

The reason for this is probably that the ppc symbol which I'm calling
actually resides in the f2k_derived namespace of the type "t", and
therefore is not found in the main program.

Now I'm not really sure how to solve this properly (since I don't have
a lot of experience in dealing with namespaces). Any hints would be
greatly appreciated.

Cheers,
Janus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: procptr_comp_139867.diff
Type: text/x-patch
Size: 24519 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080901/aca86d51/attachment.bin>


More information about the Fortran mailing list