[Patch, fortran] PR28630 - ICE due to a module function returning a derived type

THOMAS Paul Richard 169137 Paul.Richard.THOMAS@cea.fr
Tue Aug 8 14:32:00 GMT 2006


:ADDPATCH fortran:

This problem created a really horrible feeling of deja vu. It
is nearly identical to PR19362, PR20244, P25391 and friends,
except that it is a derived type function that causes the fun
instead of a variable.

I quickly fixed the problem in the same fashion as the previous
PRs but decided, instead, to do a proper job and clean out the
dog's dinner that I had left in trans_types.c from the previous
fixes. (It was not so bad but it just did not look right sitting
in trans-types.c and had been on my conscience ever since.).

I knew at the time that the association of derived types should
be possible in the front-end but was unable to find a way to
implement it.  Looking at the attached patch, I am not sure why
I found it so difficult.

The trick turned out to do some fairly simple modifications to
symbol.c(gfc_use_derived) that force a check in the parent
namespace, if it exists, for identical derived types, including
those use associated derived types that have been renamed. Most
of the contained, derived type symbols are cleaned up on the
spot, except those that have been renamed. This latter group
have to wait for the general clean up at the end of compilation
because the search for them turned out to be complicated by the
possibility of multiple associations to the same use associated
derived type (see used_dummy_types_2.f90 for examples of this).
The testcase is a deja-gnu-ified version of the testcase
submitted to the list.

Regtested on Cygwin_NT/PIV.  Also, I have built and tested
tonto-2.3 with the patch; this uncovered a problem with
interfaces and provides a comprehensive check that type
association is working correctly.

OK for trunk and 4.1?

Paul

2006-08-06 Paul Thomas <pault@gcc.gnu.org>

	PR fortran/28630
	* gfortran.h : Eliminate gfc_dt_list structure and the
	reference to it in gfc_namespace.
	* resolve.c (resolve_fl_derived): Remove the building of
	the list of derived types for the current namespace.
	* symbol.c (find_renamed_type): New function to find
	renamed derived types by symbol name rather than symtree
	name.
	(gfc_use_derived): Search parent namespace for identical
	derived type and use it, even if local version is complete,
	except in interface bodies. Ensure that renamed derived
	types are found by call to find_renamed_type.
	(gfc_free_dt_list): Remove.
	(gfc_free_namespace): Remove call to previous.
	* trans-types.c (copy_dt_decls_ifequal): Remove.
	(gfc_get_derived_type): Remove all the paraphenalia for
	association of derived types, including calls to previous.

2006-08-06 Paul Thomas <pault@gcc.gnu.org>

	PR fortran/28630
	* gfortran.dg/used_types_2.f90: New test.


 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr28630.diff
Type: application/octet-stream
Size: 9142 bytes
Desc: pr28630.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060808/bae5f93f/attachment.obj>


More information about the Gcc-patches mailing list