[4.5, Patch, Fortran] PR 36704: Procedure pointer as function result

Janus Weil jaydub66@googlemail.com
Wed Apr 8 09:16:00 GMT 2009


Hi all,

here is an updated version of my patch for procedure pointer function
results. It's basically the same as the last version I posted,
re-diffed to current trunk, with slightly enhanced test cases. For
details on how my implementation works see my previous messages in
this thread.

I would consider the patch rather complete by now, although I can not
exclude the possibility that someone breaks it with some even more
weird and exotic test cases than I have come up with. If someone
manages to do that, I'm glad to fix it. If not: Ok for trunk?
(Regtested on x86_64-unknown-linux-gnu)

Cheers,
Janus


2009-04-08  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/36704
	* decl.c (add_hidden_procptr_result): New function for handling
	procedure pointer return values by adding a hidden result variable.
	(variable_decl,match_procedure_decl,gfc_match_function_decl,
	gfc_match_subroutine,gfc_match_end,attr_decl1): Handle procedure pointer
	return values.
	* parse.c (parse_interface): Add EXTERNAL attribute only after
	FUNCTION/SUBROUTINE declaration is complete.
	* primary.c (replace_hidden_procptr_result): New function for replacing
	function symbol by hidden result variable.
	(gfc_match_rvalue,match_variable): Replace symbol by hidden result
	variable.
	* resolve.c (resolve_contained_fntype,resolve_function,resolve_variable,
	resolve_symbol): Allow for procedure pointer function results.
	(resolve_fl_procedure): Conflict detection moved here from
	'check_conflict'.
	* symbol.c (gfc_check_function_type): Allow for procedure pointer
	function results.
	(check_conflict): Move some conflict detection to resolution stage.
	* trans-types.c (gfc_sym_type,gfc_get_function_type): Handle hidden
	result variables.


2009-04-08  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/36704
	* gfortran.dg/external_procedures_1.f90: Modified.
	* gfortran.dg/proc_ptr_result_1.f90: New.
	* gfortran.dg/proc_ptr_result_2.f90: New.
	* gfortran.dg/proc_ptr_result_3.f90: New.



2009/3/12 Janus Weil <jaydub66@googlemail.com>:
> Hi Paul,
>
>> I'll review the patch in full tonight.
>
> thanks, that would be great. I made another small addition in
> resolve.c (resolve_variable), fixing an error when a procptr returning
> function is used as an actual argument (error: "Symbol ... has no
> IMPLICIT type"), and extended proc_ptr_15.f90 slightly.
>
> Note: In the PR two c.l.f. posts are linked which contain further test cases:
>
> http://groups.google.com/group/comp.lang.fortran/msg/7bddd7097fb985a5
> http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/e0d04d755453a2a5
>
> The first one ("program gptr") still doesn't compile. I think it is
> invalid. However, I fixed all the problems this made in connection
> with procptr return values.
>
> The second c.l.f. reference contains several variants of a program
> labeled "recursive_argument". I verified that versions 1 to 3 are
> working with my patch and all give the same output. We could add
> recursive_argument1.f90 as an additional test case.
>
> As before: no regressions.
>
> Cheers,
> Janus
>
>
>
>
>> On Wed, Mar 11, 2009 at 5:08 PM, Janus Weil <jaydub66@googlemail.com> wrote:
>>> Hi all,
>>>
>>> here goes another update to my procptr result patch. After a private
>>> review by Paul, I made a small modification to stick to the original
>>> error messages in external_procedures_1.f90 (which is now compiled
>>> with -std=f95). Moreover ...
>>>
>>>
>>>> All the examples in proc_ptr_14.f90 are working now. Only the
>>>> construct in proc_ptr_15.f90 still gives me headaches. Will try to
>>>> sort that out soon.
>>>
>>> I finally managed to get the beast in proc_ptr_15.f90 working, and
>>> added two more variants of it. The patch seems pretty complete to me
>>> by now, and I fail to find any more exotic test cases. There have been
>>> a few reviews already, but I am still missing approval.
>>>
>>> Regression-tested on x86_64-unknown-linux-gnu. Ok for 4.5?
>>>
>>> Cheers,
>>> Janus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr36704_2.diff
Type: text/x-patch
Size: 15933 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20090408/d9b35657/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: proc_ptr_result_1.f90
Type: text/x-fortran
Size: 2642 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20090408/d9b35657/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: proc_ptr_result_2.f90
Type: text/x-fortran
Size: 959 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20090408/d9b35657/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: proc_ptr_result_3.f90
Type: text/x-fortran
Size: 1069 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20090408/d9b35657/attachment-0003.bin>


More information about the Fortran mailing list