From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27031 invoked by alias); 9 Aug 2013 06:00:18 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 26935 invoked by uid 48); 9 Aug 2013 06:00:14 -0000 From: "janus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/44978] derived types are resolved more than once Date: Fri, 09 Aug 2013 06:00:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 4.6.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: janus at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-08/txt/msg00512.txt.bz2 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