This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Janus Weil wrote:
here is my patch for procedure pointers as function result. The easy
case of procptr function results (i.e. using a result variable) is
already working on 4.4 trunk. This patch has the ambition to also make
the harder cases work where no result variable is used. After thinking
about it for a while, I came to the conclusion that the best way of
implementing this would be to add a "hidden" result variable for those
cases where no actual RESULT statement is used. The primary motivation
for this is that the interface of the returned procptr must be kept
separate from the interface of the function which returns the procptr,
i.e. we need two separate symbols. The hidden result variable should
have a name which is not a valid Fortran variable name, and I simply
chose "ppr@" (for procedur pointer result, plus the @ to make it
invalid). If anyone thinks this is a poor choice for some reason, I
can easily change this of course.

Hi Janus,


thanks for this patch! Your plan about the hidden result variable seems fine with me, but I've not yet had time to look at the patch (and am probably not the best one to review it in general). I will try to read through it though and post comments if I have some :)

It seems 4.5-time has started for gfortran by now... So then I will take up type-bound procedures again and start on DEFERRED ;)

Cheers,
Daniel

I also attached a testcase, which should give you an idea of what the
patch is able to handle. I tried to include all the different ways to
declare a procedure pointer, and hope I forgot none. Possibly there
are still some details missing, but I'd like to have the general
concept of the patch reviewed already. Maybe someone even has an idea
how this can be done in a simpler way. I think it's kind of tricky.
The patch actually grew piece by piece, since I started with the easy
cases and made my way towards the harder ones. Also I'd appreciate it
very much if someone could test the patch from a "user's perspective",
to uncover those usage cases that I am missing.

Regtested on i686-pc-linux-gnu without any failures.

Cheers,
Janus



2008-12-06 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.
	* primary.c (match_variable): Replace symbol with hidden result
	variable.
	* resolve.c (resolve_contained_fntype): 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.


2008-12-06 Janus Weil <janus@gcc.gnu.org>


	PR fortran/36704
	* gfortran.dg/external_procedures_1.f90: Modified.
	* gfortran.dg/proc_ptr_13.f90: New.



--
Done:  Arc-Bar-Cav-Rog-Sam-Val-Wiz
To go: Hea-Kni-Mon-Pri-Ran-Tou


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]