Procedure Pointers: a first patch
Janus Weil
jaydub66@googlemail.com
Wed Jun 25 22:25:00 GMT 2008
Hi Tobi, hi all,
>>> Well, the problem is that the procedure pointer is passed as value and
>>> not as reference.
>>> See http://gcc.gnu.org/ml/fortran/2008-05/msg00299.html
>
> Try the attached patch (on top of your patch) and the attached test program:
thanks a lot for taking care of this. I'm sorry have not yet managed
to look into this myself, but my diploma thesis is keeping me insanely
busy at the moment.
> I'm not sure whether my patch is really elegant, but it seems to work ;-)
I'd say functionality beats elegance here :)
And indeed your patch works very well. I included it in the updated
version of the complete procptr patch, which is attached. Your patch
also fixes my test case "proc_ptr_6.f90". I included your test case
into my series as "proc_ptr_7.f90", and also included Joost's original
test case from PR32580 as "proc_ptr_8.f90".
So, now that procptrs as actual arguments are working, do you think we
can dare to commit the patch? Of course it does not fully implement
all aspects of procedure pointers yet. Some things which are still
missing are: procptr components, functions returning procptrs,
procptrs in COMMON, some checking etc. On the other hand the patch
already provides a solid implementation of the most important procptr
functionality (which can surely stand up to what most other compilers
have so far). The remaining features could be added in a follow-up
patch. An early commit would also allow for wider testing.
Any other arguments for/against committing now/later? Or is there
anything else we should definitely include in the first commit?
Cheers,
Janus
2008-06-25 Janus Weil <janus@gcc.gnu.org>
Tobias Burnus <burnus@net-b.de>
Paul Thomas <pault@gcc.gnu.org>
PR fortran/32580
* gfortran.h (struct gfc_symbol): New member "proc_pointer".
* check.c (gfc_check_associated,gfc_check_null): Implement
procedure pointers.
* decl.c (match_procedure_decl): Ditto.
* expr.c (gfc_check_pointer_assign,gfc_check_assign_symbol): Ditto.
* interface.c (compare_actual_formal): Ditto.
* match.h: Ditto.
* match.c (gfc_match_pointer_assignment): Ditto.
* parse.c (parse_interface): Ditto.
* primary.c (gfc_match_rvalue,match_variable): Ditto.
* resolve.c (resolve_fl_procedure): Ditto.
* symbol.c (check_conflict,gfc_add_external,gfc_add_pointer,
gfc_copy_attr,gen_fptr_param,build_formal_args): Ditto.
* trans-decl.c (get_proc_pointer_decl,gfc_get_extern_function_decl,
create_function_arglist): Ditto.
* trans-expr.c (gfc_conv_variable,gfc_conv_function_val,
gfc_conv_function_call,gfc_trans_pointer_assignment): Ditto.
2008-06-25 Janus Weil <janus@gcc.gnu.org>
Tobias Burnus <burnus@net-b.de>
PR fortran/32580
* gfortran.dg/c_f_pointer_tests_3.f90: Updated.
* gfortran.dg/proc_decl_1.f90: Updated.
* gfortran.dg/proc_ptr_1.f90: New.
* gfortran.dg/proc_ptr_2.f90: New.
* gfortran.dg/proc_ptr_3.f90: New.
* gfortran.dg/proc_ptr_4.f90: New.
* gfortran.dg/proc_ptr_5.f90: New.
* gfortran.dg/proc_ptr_6.f90: New.
* gfortran.dg/proc_ptr_7.f90: New.
* gfortran.dg/proc_ptr_8.f90: New.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: procptr137120.diff
Type: text/x-patch
Size: 22233 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080625/a8484c1a/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: proc_ptr_1.f90
Type: application/octet-stream
Size: 1494 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080625/a8484c1a/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: proc_ptr_2.f90
Type: application/octet-stream
Size: 356 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080625/a8484c1a/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: proc_ptr_3.f90
Type: application/octet-stream
Size: 656 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080625/a8484c1a/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: proc_ptr_4.f90
Type: application/octet-stream
Size: 739 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080625/a8484c1a/attachment-0003.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: proc_ptr_5.f90
Type: application/octet-stream
Size: 543 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080625/a8484c1a/attachment-0004.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: proc_ptr_6.f90
Type: application/octet-stream
Size: 635 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080625/a8484c1a/attachment-0005.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: proc_ptr_7.c
Type: text/x-csrc
Size: 155 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080625/a8484c1a/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: proc_ptr_7.f90
Type: application/octet-stream
Size: 887 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080625/a8484c1a/attachment-0006.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: proc_ptr_8.c
Type: text/x-csrc
Size: 141 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080625/a8484c1a/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: proc_ptr_8.f90
Type: application/octet-stream
Size: 654 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080625/a8484c1a/attachment-0007.obj>
More information about the Fortran
mailing list