From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16622 invoked by alias); 19 Jun 2012 10:47:10 -0000 Received: (qmail 16612 invoked by uid 22791); 19 Jun 2012 10:47:09 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 19 Jun 2012 10:46:56 +0000 From: "janus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/53694] [OOP] GENERIC type-bound procs should be available without part-ref syntax Date: Tue, 19 Jun 2012 10:47: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-Keywords: rejects-valid 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-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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 X-SW-Source: 2012-06/txt/msg01257.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53694 --- Comment #6 from janus at gcc dot gnu.org 2012-06-19 10:46:56 UTC --- (In reply to comment #5) > Btw, I'm not completely convinced yet that the code in comment #0 (and #4) is > really legal. In any case, here is a simple draft patch, which makes the code in comment 4 work (at least when the ONLY clause in the USE statement is removed): Index: gcc/fortran/decl.c =================================================================== --- gcc/fortran/decl.c (revision 188334) +++ gcc/fortran/decl.c (working copy) @@ -8374,12 +8374,20 @@ gfc_match_generic (void) { const bool is_op = (op_type == INTERFACE_USER_OP); gfc_symtree* st; + gfc_symbol *gensym; st = gfc_new_symtree (is_op ? &ns->tb_uop_root : &ns->tb_sym_root, name); gcc_assert (st); st->n.tb = tb; + /* Create non-typebound generic symbol. */ + if (gfc_get_symbol (name, NULL, &gensym)) + return MATCH_ERROR; + if (!gensym->attr.generic + && gfc_add_generic (&gensym->attr, gensym->name, NULL) == FAILURE) + return MATCH_ERROR; + break; } Index: gcc/fortran/resolve.c =================================================================== --- gcc/fortran/resolve.c (revision 188335) +++ gcc/fortran/resolve.c (working copy) @@ -11125,6 +11125,26 @@ specific_found: return FAILURE; } + /* Add target to (non-typebound) generic symbol. */ + if (!p->u.generic->is_operator) + { + gfc_symbol *gensym; + if (gfc_get_symbol (name, NULL, &gensym)) + return FAILURE; + if (gensym) + { + gfc_interface *head, *intr; + head = gensym->generic; + intr = gfc_get_interface (); + intr->sym = target->specific->u.specific->n.sym; + intr->where = gfc_current_locus; + intr->sym->declared_at = gfc_current_locus; + intr->next = head; + gensym->generic = intr; + gfc_commit_symbol (gensym); + } + } + /* Check those already resolved on this type directly. */ for (g = p->u.generic; g; g = g->next) if (g != target && g->specific