From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5100 invoked by alias); 15 Nov 2007 12:31:28 -0000 Received: (qmail 5082 invoked by uid 22791); 15 Nov 2007 12:31:26 -0000 X-Spam-Check-By: sourceware.org Received: from zs01.physik.fu-berlin.de (HELO zs01.physik.fu-berlin.de) (160.45.35.150) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 15 Nov 2007 12:31:22 +0000 Received: from ith.physik.fu-berlin.de ([160.45.32.115] helo=[127.0.0.1]) by zs01.physik.fu-berlin.de with esmtp (Exim 4.63) (envelope-from ) id 1IsdsK-0008HP-Q6; Thu, 15 Nov 2007 13:31:19 +0100 Message-ID: <473C3C16.1090901@net-b.de> Date: Thu, 15 Nov 2007 14:33:00 -0000 From: Tobias Burnus User-Agent: Thunderbird 2.0.0.6 (X11/20070801) MIME-Version: 1.0 To: "'fortran@gcc.gnu.org'" , gcc-patches CC: Janus Weil Subject: [Patch, Fortran] PR33917 - PROCEDURE - check for interfaces from later procedure-declaration-stmts Content-Type: multipart/mixed; boundary="------------040506090700060302070609" X-ZEDV-Virus-Scanned: No viruses found. [ClamAV 0.90.1/4798/Thu Nov 15 08:59:49 2007] X-ZEDV-Spam-Level: ---- X-ZEDV-Spam-Checker-Version: SpamAssassin 3.1.7-deb (2006-10-05) on zs01.physik.fu-berlin.de X-ZEDV-Spam-Status: No, score=-4.2 required=5.0 tests=ALL_TRUSTED,BAYES_00,SUBJ_HAS_UNIQ_ID autolearn=ham version=3.1.7-deb X-ZEDV-Spam-Report: * 0.2 SUBJ_HAS_UNIQ_ID Subject contains a unique ID * -1.8 ALL_TRUSTED Passed through trusted hosts only via SMTP * -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% * [score: 0.0000] Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2007-11/txt/msg00849.txt.bz2 This is a multi-part message in MIME format. --------------040506090700060302070609 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Content-length: 551 :ADDPATCH fortran: PROCEDURE() :: proc allows for the interface either procedures with explicit interfaces coming from an INTERFACE, or being host/use associated procedures. Additionally, the interface name can also be declared in another PROCEDURE-declaration statement - with the restriction that that statement needs to come before the interface is used: "C1212 (R1215) [...] If name is declared by a procedure-declaration-stmt it shall be previously declared." Build and regression tested on x86-64. Ok for the trunk? Tobias --------------040506090700060302070609 Content-Type: text/plain; name="procedure.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="procedure.diff" Content-length: 2908 2007-11-15 Tobias Burnus PR fortran/33917 * decl.c (match_procedure_decl): Pre-resolve interface. * resolve.c (resolve_symbol): Reject interfaces later declared in procedure statements. 2007-11-15 Tobias Burnus PR fortran/33917 * gfortran.dg/proc_decl_11.f90: New. Index: gcc/fortran/decl.c =================================================================== --- gcc/fortran/decl.c (Revision 130194) +++ gcc/fortran/decl.c (Arbeitskopie) @@ -3946,6 +3946,12 @@ match_procedure_decl (void) /* Various interface checks. */ if (proc_if) { + /* Resolve interface if possible. That way, attr.procedure is only set + if it is declared by a later procedure-declaration-stmt, which is + invalid per C1212. */ + while (proc_if->interface) + proc_if = proc_if->interface; + if (proc_if->generic) { gfc_error ("Interface '%s' at %C may not be generic", proc_if->name); Index: gcc/fortran/resolve.c =================================================================== --- gcc/fortran/resolve.c (Revision 130194) +++ gcc/fortran/resolve.c (Arbeitskopie) @@ -7615,8 +7615,10 @@ resolve_symbol (gfc_symbol *sym) if (sym->attr.procedure && sym->interface && sym->attr.if_source != IFSRC_DECL) { - while (sym->interface->interface) - sym->interface = sym->interface->interface; + if (sym->interface->attr.procedure) + gfc_error ("Interface '%s', used by procedure '%s' at %L, is declared " + "in a later PROCEDURE statement", sym->interface->name, + sym->name,&sym->declared_at); /* Get the attributes from the interface (now resolved). */ if (sym->interface->attr.if_source || sym->interface->attr.intrinsic) Index: gcc/testsuite/gfortran.dg/proc_decl_11.f90 =================================================================== --- gcc/testsuite/gfortran.dg/proc_decl_11.f90 (Revision 0) +++ gcc/testsuite/gfortran.dg/proc_decl_11.f90 (Revision 0) @@ -0,0 +1,34 @@ +! { dg-do compile } +! PR fortran/33917 +! +! Depending, in which order the symbol tree +! was walked in resolve, gfortran resolved +! p6 before p4; thus there was no explicit +! interface available for p4 and an error +! was printed. (This is a variant of proc_decl_2.f90) +! +! Additionally, the following contrain was not honoured: +! "C1212 (R1215) [...] If name is declared by a procedure-declaration-stmt +! it shall be previously declared." ("name" = interface-name) +! +program s + implicit none + procedure() :: q2 + procedure() :: q3 + procedure() :: q5 + procedure(sub) :: p4 + procedure(p4) :: p6 +contains + subroutine sub + end subroutine +end program s + +subroutine test + implicit none + abstract interface + subroutine sub() + end subroutine sub + end interface + procedure(p4) :: p6 ! { dg-error "declared in a later PROCEDURE statement" } + procedure(sub) :: p4 +end subroutine test --------------040506090700060302070609--