[4.5, Patch, Fortran] PR 36704: Procedure pointer as function result
Mikael Morin
mikael.morin@tele2.fr
Mon Dec 8 16:16:00 GMT 2008
Janus Weil wrote:
> Hi all,
>
> here is my patch for procedure pointers as function result.
Hi,
it looks like nobody wants to review it. :D
Ok, I'll do it (Disclaimer: this is my first time).
I think your hidden result symbol is Ok. Giving the same name to the
function and its result has always been making me confused, but it's
even worse with function pointers (cf your h case).
Now, the details.
About this:
+
+ if (add_hidden_procptr_result (sym) == SUCCESS)
+ sym = sym->result;
+
Is it really needed in the case of a subroutine ?
+ sym = sym->result;
sym->name becomes invalid. Try this for example:
--- proc_ptr_13.f90 2008-12-08 16:44:13.000000000 +0100
+++ proc_ptr_13.f90.old 2008-12-08 16:44:08.000000000 +0100
@@ -57,7 +57,7 @@
function f()
pointer :: f
interface
- integer function f(x) bind(c)
+ integer function f(x)
integer :: x
end function
end interface
+ else if (strcmp (block_name, "ppr@") == 0
This is hard to understand if it's not used close to where "ppr@" was
defined. One should either use sym->attr.proc_pointer && (...) or add a
comment before explaining what we are doing or simply reminding that
ppr stands for procedure pointer result.
Looks good otherwise. I failed to make it fail.
Thanks for it.
Mikael
PS: Why not add a runtime test for h and i as well ?
PPS: How are generic intrinsics handled? I tried this, and it doesn't
complain. (And chooses the real_4 specific according to gdb).
--- proc_ptr_13.f90.old 2008-12-08 16:44:08.000000000 +0100
+++ proc_ptr_13.f90 2008-12-08 17:29:53.000000000 +0100
@@ -90,10 +90,11 @@
pointer :: i
interface
function i(x)
- real :: i,x
+ real :: i
+ real(8) :: x
end function i
end interface
i => sin
More information about the Fortran
mailing list