[Patch, Fortran] PR 42048 & 42167

Janus Weil janus@gcc.gnu.org
Wed Nov 25 13:15:00 GMT 2009


Hi all,

both of the PRs in the subject line deal with the problem of detecting
if a symbol is the return value of an encompassing function.

The simplistic way to do that is to check if the symbol equals the
proc_name of the current ns (which is done in several places throught
the front end). However, it's not that simple in general. Firstly, one
has to deal with internal functions nested in other functions (this
was mostly taken care of already). Second, we now have local
namespaces, e.g. for BLOCK and SELECT TYPE statements, and these might
be arbitrarily nested. So, as a general solution, one has to look
through the current namespace and all its parents, to find out if the
symbol is a function return value. [Note that what I'm talking about
only applies to functions without an explicit result variable.]

To fix the two PRs I created a function which performs the check
described above. Using this function in gfc_match_rvalue fixes
PR42167, and in gfc_match_call it fixes the remaining issues of
PR42048 (comment #4). I also tried to use it in other places where it
does apply, but I'm not sure if I caught all of them.

The patch was regtested on x86_64-unknown-linux-gnu. Ok for trunk?

Cheers,
Janus


2009-11-25  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/42048
	PR fortran/42167
	* gfortran.h (gfc_is_function_return_value): New prototype.
	* match.c (gfc_match_call): Use new function
	'gfc_is_function_return_value'.
	* primary.c (gfc_is_function_return_value): New function to check if a
	symbol is the return value of an encompassing function.
	(match_actual_arg,gfc_match_rvalue,match_variable): Use new function
	'gfc_is_function_return_value'.
	* resolve.c (resolve_common_blocks,resolve_actual_arglist): Ditto.

2009-11-25  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/42048
	PR fortran/42167
	* gfortran.dg/select_type_10.f03: New test case.
	* gfortran.dg/typebound_call_11.f03: Extended test case.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr42167_42048.diff
Type: application/octet-stream
Size: 5184 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20091125/dfc96ba4/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: select_type_10.f03
Type: application/octet-stream
Size: 676 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20091125/dfc96ba4/attachment-0001.obj>


More information about the Gcc-patches mailing list