From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23197 invoked by alias); 1 Mar 2011 16:27:26 -0000 Received: (qmail 23188 invoked by uid 22791); 1 Mar 2011 16:27:25 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 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, 01 Mar 2011 16:27:21 +0000 From: "mikael at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/42769] [OOP] ICE in resolve_typebound_procedure X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: ice-on-valid-code, patch X-Bugzilla-Severity: normal X-Bugzilla-Who: mikael at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P5 X-Bugzilla-Assigned-To: janus at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.6.0 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 Date: Tue, 01 Mar 2011 16:27:00 -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 X-SW-Source: 2011-03/txt/msg00094.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42769 --- Comment #34 from Mikael Morin 2011-03-01 16:26:53 UTC --- The hack in comment 32 compiles correctly comment 24, but rejects the following variant (with the type-bound call in a subroutine) with: use mod2 1 Error: Name 'my_get' at (1) is an ambiguous reference to 'my_get' from module 'mod2' module mod1 type :: t1 contains procedure, nopass :: get => my_get end type contains subroutine my_get() print *,"my_get (mod1)" end subroutine end module module mod2 contains subroutine my_get() ! must have the same name as the function in mod1 print *,"my_get (mod2)" end subroutine end module use mod2 use mod1 ! order of use statements is important type(t1) :: a call call_get contains subroutine call_get call a%get() end subroutine call_get end The reason is that the following code in resolve_call reloads the procedure symbol from the current namespace. This could be disabled with a flag, but it would just make the hack uglier. if (csym && gfc_current_ns->parent && csym->ns != gfc_current_ns) { gfc_symtree *st; gfc_find_sym_tree (csym->name, gfc_current_ns, 1, &st); sym = st ? st->n.sym : NULL; if (sym && csym != sym && sym->ns == gfc_current_ns && sym->attr.flavor == FL_PROCEDURE && sym->attr.contained) { sym->refs++; if (csym->attr.generic) c->symtree->n.sym = sym; else c->symtree = st; csym = c->symtree->n.sym; } }