Procedure Pointers: a first patch

Janus Weil jaydub66@googlemail.com
Sat Jun 14 22:55:00 GMT 2008


Hi Tobias, hi all,

> My feeling is that one does not need a tri-state, see below.

I think you're actually right, and I'm glad you are, because I didn't
really like the tristate solution (I just failed to see the solution
you found).


> Let's try whether I can come up with a scheme where pointer:1 +
> procpointer:1 is enough.
>
> In resolve.c do:
>
> if (sym->attr.pointer && sym->attr.external && sym->attr.if_source !=
> IFSRC_IFBODY)
>  {
>   sym->attr.pointer = 0;
>   sym->attr.procpointer = 1;
>  }
>
> In decl.c's gfc_match_function_decl:
>
> if (gfc_current_state () == COMP_INTERFACE && sym->attr.pointer)
>  {
>   sym->attr.pointer = 0;
>   sym->attr.procpointer = 1;
>  }
>
> and in decl.c's attr_decl1:
>
> if (gfc_current_state () != COMP_INTERFACE
>   && sym->attr.if_source == IFSRC_IFBODY)
>  {
>   current_attr.pointer = 0;
>   current_attr.procpointer = 1;
>  }
>
> I think this should work - or have I missed something?

No, I think it's fine. Thanks a lot for pointing this out. Of course
you missed some details, but I get the idea (which is a good one). And
it seems to work indeed.
I included (a free interpretation of) this in the patch, killing the
three regressions I saw before (right now I see only
parameter_array_init_4.f90 failing, which I guess was broken by
someone else).
I also attached some test cases ("proc_ptr_4.f90" contains the most
recent examples, including your "proc-pointer to a pointer-valued
function"). All of these should work now.


> PS: It should be enough to write to fortran@ (and when the patch is ready to
> gcc-patches@) without CCing all the people. At least in my case, I got the
> email trice.

Sorry about that. Too much "reply to all".

Btw,I will have a look at the issues from your other mail tomorrow.

Cheers,
Janus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: procptr136782.diff
Type: text/x-patch
Size: 15934 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080614/b76493ff/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: proc_ptr_1.f90
Type: text/x-fortran
Size: 1213 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080614/b76493ff/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: proc_ptr_2.f90
Type: text/x-fortran
Size: 255 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080614/b76493ff/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: proc_ptr_3.f90
Type: text/x-fortran
Size: 612 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080614/b76493ff/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: proc_ptr_4.f90
Type: text/x-fortran
Size: 647 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080614/b76493ff/attachment-0004.bin>


More information about the Fortran mailing list