[Patch, fortran] PR24092 and PR24158 - recursive derived types

Paul Thomas paulthomas2@wanadoo.fr
Sat Oct 8 09:17:00 GMT 2005


:ADDPATCH fortran:

These patches deal with the various manifestations of recursive derived 
types that have recently been discussed on the list.

The first(PR24092) concerns the ICE that occurs in trans-types.c 
(gfc_get_derived_type), when a derived type specification includes a 
pointer to a derived type that has not yet been defined.  The function 
runs through the components building up a field list.  When a derived 
type is encountered, it sets about, by recursion, building the derived 
type if this has not already happened.  This has the effect that the 
backend_decl for the component is found to exist, at the end of the 
first call, and runs afoul of the gcc_assert (!c->backend_decl).  The 
fix replaces the gcc_assert by an if statement, thereby retaining the 
existing backend_decl, since it is this that is added to the field list.

The second(PR24158) concerns recursion, where the undefined component is 
a derived type, rather than a pointer.   gfortran makes a determined 
effort to build this structure, with the inevitable result!  The 
discussion on the list centred on the choice between detecting the 
recursion or, following the standard, only permitting  already defined 
derived type components.  Since the consensus was that the standard 
should be adherred to, the patch does the latter by repairing the bit of 
broken code in decl.c (gfc_match_data_decl) that was meant to take care 
of this.  I have detected other circumstances in which an attempt is 
made to make use of an undefined derived type; typically these involve 
implicit typing and use association.  I have put a catch-all 
backstop(wicket keeper...) in resolve_symbol to produce an error in 
these cases.

Bubblestrapped and regtested under Cygwin_NT/Athlon.  OK for mainline 
and 4.0?

Paul T
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: submit.txt
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20051008/e9f5c708/attachment.txt>


More information about the Fortran mailing list