From patchwork Thu Jun 2 16:20:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 98443 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 5EA94B6F9F for ; Fri, 3 Jun 2011 02:21:06 +1000 (EST) Received: (qmail 26146 invoked by alias); 2 Jun 2011 16:20:58 -0000 Received: (qmail 26110 invoked by uid 22791); 2 Jun 2011 16:20:54 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from troutmask.apl.washington.edu (HELO troutmask.apl.washington.edu) (128.95.76.21) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 02 Jun 2011 16:20:38 +0000 Received: from troutmask.apl.washington.edu (localhost.apl.washington.edu [127.0.0.1]) by troutmask.apl.washington.edu (8.14.4/8.14.4) with ESMTP id p52GKbwd018234; Thu, 2 Jun 2011 09:20:37 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.14.4/8.14.4/Submit) id p52GKbZC018233; Thu, 2 Jun 2011 09:20:37 -0700 (PDT) (envelope-from sgk) Date: Thu, 2 Jun 2011 09:20:37 -0700 From: Steve Kargl To: Thomas Koenig Cc: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [PATCH] PR fortran/49265 -- allow for double colon in module procedure statement Message-ID: <20110602162036.GA18169@troutmask.apl.washington.edu> References: <20110602151632.GA8891@troutmask.apl.washington.edu> <4DE7B361.9090803@netcologne.de> Mime-Version: 1.0 Content-Disposition: inline In-Reply-To: <4DE7B361.9090803@netcologne.de> User-Agent: Mutt/1.4.2.3i Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On Thu, Jun 02, 2011 at 05:59:29PM +0200, Thomas Koenig wrote: > Hi Steve, > > it seems that, with your patch, > > interface foo > module procedure::bar > end interface > > is rejected, as is > > interface foo > module procuedure:: bar > end interface > > Is this the way it is supposed to be? > Oh phew. Good catch. I wasn't dealing with the possible white space issues. Here's an updated patch and testcase. Index: gcc/fortran/ChangeLog =================================================================== --- gcc/fortran/ChangeLog (revision 174566) +++ gcc/fortran/ChangeLog (working copy) @@ -1,3 +1,11 @@ +2011-06-02 Steven G. Kargl + + PR fortran/49265 + * decl.c (gfc_match_modproc): Allow for a double colon in a module + procedure statement. + * parse.c ( decode_statement): Deal with whitespace around :: in + gfc_match_modproc. + 2011-05-31 Tobias Burnus PR fortran/18918 Index: gcc/fortran/decl.c =================================================================== --- gcc/fortran/decl.c (revision 174566) +++ gcc/fortran/decl.c (working copy) @@ -7016,6 +7016,7 @@ gfc_match_modproc (void) char name[GFC_MAX_SYMBOL_LEN + 1]; gfc_symbol *sym; match m; + locus old_locus; gfc_namespace *module_ns; gfc_interface *old_interface_head, *interface; @@ -7044,10 +7045,23 @@ gfc_match_modproc (void) end up with a syntax error and need to recover. */ old_interface_head = gfc_current_interface_head (); + /* Check if the F2008 optional double colon appears. */ + gfc_gobble_whitespace (); + old_locus = gfc_current_locus; + if (gfc_match ("::") == MATCH_YES) + { + if (gfc_notify_std (GFC_STD_F2008, "Fortran 2008: double colon in " + "MODULE PROCEDURE statement at %L", &old_locus) + == FAILURE) + return MATCH_ERROR; + } + else + gfc_current_locus = old_locus; + for (;;) { - locus old_locus = gfc_current_locus; bool last = false; + old_locus = gfc_current_locus; m = gfc_match_name (name); if (m == MATCH_NO) @@ -7059,6 +7073,7 @@ gfc_match_modproc (void) current namespace. */ if (gfc_match_eos () == MATCH_YES) last = true; + if (!last && gfc_match_char (',') != MATCH_YES) goto syntax; Index: gcc/fortran/parse.c =================================================================== --- gcc/fortran/parse.c (revision 174566) +++ gcc/fortran/parse.c (working copy) @@ -399,7 +399,7 @@ decode_statement (void) break; case 'm': - match ("module% procedure% ", gfc_match_modproc, ST_MODULE_PROC); + match ("module% procedure", gfc_match_modproc, ST_MODULE_PROC); match ("module", gfc_match_module, ST_MODULE); break; Index: gcc/testsuite/ChangeLog =================================================================== --- gcc/testsuite/ChangeLog (revision 174566) +++ gcc/testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2011-06-02 Steven G. Kargl + + PR fortran/49265 + * gfortran.dg/module_procedure_double_colon.f90: New test. + 2011-06-02 Eric Botcazou Hans-Peter Nilsson Index: gcc/testsuite/gfortran.dg/module_procedure_double_colon.f90 =================================================================== --- gcc/testsuite/gfortran.dg/module_procedure_double_colon.f90 (revision 0) +++ gcc/testsuite/gfortran.dg/module_procedure_double_colon.f90 (revision 0) @@ -0,0 +1,24 @@ +! { dg-do compile } +! { dg-options "-std=f95" } +! +! PR fortran/49265 +! Contributed by Erik Toussaint +! +module m1 + implicit none + interface foo + module procedure::bar ! { dg-error "double colon" } + module procedure ::bar_none ! { dg-error "double colon" } + module procedure:: none_bar ! { dg-error "double colon" } + end interface +contains + subroutine bar + end subroutine + subroutine bar_none(i) + integer i + end subroutine + subroutine none_bar(x) + real x + end subroutine +end module +! { dg-final { cleanup-modules "m1" } }