http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44978
--- Comment #5 from janus at gcc dot gnu.org --- (In reply to janus from comment #3) > To get rid of all of them, I would propose to use the gfc_symbol.resolved > field (this is already done for ordinary symbols in 'resolve_symbol'). For > derived types, however, one may have to add another value of this flag > (other than '0' and '1') to distinguish between the two different resolution > levels of resolve_fl_derived0 vs resolve_fl_derived. The following draft patch does exactly this and gets the error count down to one for comment 1 and down to two for comment 1 and 4: Index: gcc/fortran/gfortran.h =================================================================== --- gcc/fortran/gfortran.h (revision 201576) +++ gcc/fortran/gfortran.h (working copy) @@ -1250,7 +1250,7 @@ typedef struct gfc_symbol /* Set if this variable is used as an index name in a FORALL. */ unsigned forall_index:1; /* Used to avoid multiple resolutions of a single symbol. */ - unsigned resolved:1; + unsigned resolved:2; int refs; struct gfc_namespace *ns; /* namespace containing this symbol */ Index: gcc/fortran/resolve.c =================================================================== --- gcc/fortran/resolve.c (revision 201576) +++ gcc/fortran/resolve.c (working copy) @@ -11962,6 +11962,10 @@ resolve_fl_derived0 (gfc_symbol *sym) gfc_symbol* super_type; gfc_component *c; + if (sym->resolved>1) + return true; + sym->resolved = 2; + if (sym->attr.unlimited_polymorphic) return true; @@ -12381,6 +12385,13 @@ resolve_fl_derived (gfc_symbol *sym) { gfc_symbol *gen_dt = NULL; + if (!resolve_fl_derived0 (sym)) + return false; + + if (sym->resolved>2) + return true; + sym->resolved = 3; + if (sym->attr.unlimited_polymorphic) return true; @@ -12422,9 +12433,6 @@ resolve_fl_derived (gfc_symbol *sym) } } - if (!resolve_fl_derived0 (sym)) - return false; - /* Resolve the type-bound procedures. */ if (!resolve_typebound_procedures (sym)) return false; @@ -12624,16 +12632,13 @@ resolve_symbol (gfc_symbol *sym) gfc_array_spec *as; bool saved_specification_expr; - if (sym->resolved) + if (sym->resolved>0) return; sym->resolved = 1; - if (sym->attr.artificial) + if (sym->attr.artificial || sym->attr.unlimited_polymorphic) return; - if (sym->attr.unlimited_polymorphic) - return; - if (sym->attr.flavor == FL_UNKNOWN || (sym->attr.flavor == FL_PROCEDURE && !sym->attr.intrinsic && !sym->attr.generic && !sym->attr.external