From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3797 invoked by alias); 21 Jul 2012 09:52:12 -0000 Received: (qmail 3786 invoked by uid 22791); 21 Jul 2012 09:52:11 -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; Sat, 21 Jul 2012 09:51:59 +0000 From: "janus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/42418] PROCEDURE: Rejects interface which is both specific and generic procedure Date: Sat, 21 Jul 2012 09:52: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-07/txt/msg01690.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42418 --- Comment #6 from janus at gcc dot gnu.org 2012-07-21 09:51:57 UTC --- The error in comment #0 should be fixable by something like the following: Index: gcc/fortran/decl.c =================================================================== --- gcc/fortran/decl.c (revision 189711) +++ gcc/fortran/decl.c (working copy) @@ -4807,9 +4807,17 @@ match_procedure_interface (gfc_symbol **proc_if) if ((*proc_if)->generic) { - gfc_error ("Interface '%s' at %C may not be generic", - (*proc_if)->name); - return MATCH_ERROR; + /* For generic interfaces, check if there is + a specific procedure with the same name. */ + gfc_interface *gen = (*proc_if)->generic; + while (gen && strcmp (gen->sym->name, (*proc_if)->name) != 0) + gen = gen->next; + if (!gen) + { + gfc_error ("Interface '%s' at %C may not be generic", + (*proc_if)->name); + return MATCH_ERROR; + } } if ((*proc_if)->attr.proc == PROC_ST_FUNCTION) { However, I wonder whether this whole generic check does not come to early. If the generic interface is declared after the PROCEDURE statement, it will not be triggered. It should probably be moved to resolve.c