This is the mail archive of the 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]

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

: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?


2006-08-06 Paul Thomas <>

	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
	(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 <>

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


Attachment: pr28630.diff
Description: pr28630.diff

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