Procedure Pointers: a first patch

Tobias Burnus burnus@net-b.de
Sun May 4 15:55:00 GMT 2008


Hi Janus,

Janus Weil wrote:
> and I have started to work on proc-pointer assignments (where I'm stuck right
> now), but haven't looked into calling proc-pointers.
>   
What puzzles me is when I look at the dump (original) is the following. For

  PROCEDURE(), POINTER :: ptr
  ptr => proc

I had expected a declaration of "ptr", however, I do not see any, one 
simply finds:

  ptr = proc;

Compare this with

  type(c_funptr) :: ptr
  ptr = c_funloc(proc)

which produces the following tree:

  void (*<T5e>) (void) ptr;
  ptr = proc;

The "void (*<T5e>) (void) ptr;" is missing in your case and I believe it 
is the reason for the GIMPLE failure. I think you need to explicitly 
handle procedure pointers in trans*.c. For c_funptr see trans-types.c 
and search for ptr_type_node.*


(Side note: Using "call ptr()" currently does not work as ptr is a 
EXPR_VARIABLE, but I think this is expected and a side effect of having 
EXPR_VARIABLE; maybe this another good reason for having EXPR_PROCEDURE?.)


Tobias,
who will have more time after Whit Monday/Pentecoste Monday in 9 days.

* I want to remark again that one should only use "ptr_type_node" (and 
thus "void (*<T5e>) (void)") for "procedure(), pointer". As soon as more 
about the interface is known, e.g. "procedure(REAL), pointer", one needs 
to create a proper declaration (e.g. "real (*<T5e>)(void)"). As interim 
solution one can use the generic ptr_type_node, which is mostly 
compatible, but the final solution should do it correctly.



More information about the Fortran mailing list