From patchwork Fri Jun 25 18:19:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 56940 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 C9B36B6F04 for ; Sat, 26 Jun 2010 04:20:21 +1000 (EST) Received: (qmail 2392 invoked by alias); 25 Jun 2010 18:20:10 -0000 Received: (qmail 2355 invoked by uid 22791); 25 Jun 2010 18:20:07 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 25 Jun 2010 18:20:00 +0000 Received: from [192.168.178.22] (port-92-204-98-222.dynamic.qsc.de [92.204.98.222]) by mx02.qsc.de (Postfix) with ESMTP id 051942196A; Fri, 25 Jun 2010 20:19:57 +0200 (CEST) Message-ID: <4C24F34D.2080209@net-b.de> Date: Fri, 25 Jun 2010 20:19:57 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.1.9) Gecko/20100317 SUSE/3.0.4 Thunderbird/3.0.4 MIME-Version: 1.0 To: gfortran , gcc patches Subject: [Patch, Fortran] F2008 - allow a semicolon at the beginning of a line 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 Fortran 2008 allows - for free format - a semicolon as first item in a line: F2003 has (3.3.1.3 Free form statement termination) "A statement may alternatively be terminated by a “;” character that appears other than in a character context or in a comment. The “;” is not part of the statement. After a “;” terminator, another statement 11 may appear on the same line, or begin on that line and be continued. A “;” shall not appear as the first 12 nonblank character on a line. [...]" F2008 has (3.3.2.5 Free form statement termination): "A statement may alternatively be terminated by a ';' character that appears other than in a character context or in a comment. The ';' is not part of the statement. After a ';' terminator, another statement may appear on the same line, or begin on that line and be continued. [...]" Similarly for fixed form: Here, the text 'A “;” shall not appear as the first nonblank character on a line, except in character position 6.' disappeared. Note: If there is a label, a ";" is still not allowed as: "If a statement is labeled, the statement shall contain a nonblank character." and as ";" does not count as statement ... Build and regtested on x86-64-linux. OK for the trunk? Tobias 2010-06-25 Tobias Burnus * parse.c (next_free, next_fixed): Allow ";" as first character. 2010-06-25 Tobias Burnus * gfortran.dg/semicolon_fixed.f: Update. * gfortran.dg/semicolon_fixed_2.f: New. * gfortran.dg/semicolon_free_2.f90: New. * gfortran.dg/semicolon_free.f90: Update. Index: gcc/fortran/parse.c =================================================================== --- gcc/fortran/parse.c (Revision 161388) +++ gcc/fortran/parse.c (Arbeitskopie) @@ -717,7 +717,9 @@ next_free (void) if (at_bol && c == ';') { - gfc_error_now ("Semicolon at %C needs to be preceded by statement"); + if (!(gfc_option.allow_std & GFC_STD_F2008)) + gfc_error_now ("Fortran 2008: Semicolon at %C without preceding " + "statement"); gfc_next_ascii_char (); /* Eat up the semicolon. */ return ST_NONE; } @@ -853,7 +855,11 @@ next_fixed (void) if (c == ';') { - gfc_error_now ("Semicolon at %C needs to be preceded by statement"); + if (digit_flag) + gfc_error_now ("Semicolon at %C needs to be preceded by statement"); + else if (!(gfc_option.allow_std & GFC_STD_F2008)) + gfc_error_now ("Fortran 2008: Semicolon at %C without preceding " + "statement"); return ST_NONE; } Index: gcc/testsuite/gfortran.dg/semicolon_fixed_2.f =================================================================== --- gcc/testsuite/gfortran.dg/semicolon_fixed_2.f (Revision 0) +++ gcc/testsuite/gfortran.dg/semicolon_fixed_2.f (Revision 0) @@ -0,0 +1,12 @@ +! { dg-do compile } +! { dg-do options "-std=f2008" } + +! PR 19259 Semicolon cannot start a line +! but it F2008 it can! + x=1; y=1; + x=2;; + x=3; + ; ! OK + ;; ! OK + 900 ; ! { dg-error "Semicolon at" } + end Index: gcc/testsuite/gfortran.dg/semicolon_fixed.f =================================================================== --- gcc/testsuite/gfortran.dg/semicolon_fixed.f (Revision 161388) +++ gcc/testsuite/gfortran.dg/semicolon_fixed.f (Arbeitskopie) @@ -1,9 +1,11 @@ ! { dg-do compile } -! PR 19259 Semicolon cannot start a line +! { dg-do options "-std=f2003" } +! +! PR 19259 Semicolon cannot start a line (in F2003) x=1; y=1; x=2;; x=3; - ; ! { dg-error "Semicolon at" } - ;; ! { dg-error "Semicolon at" } + ; ! { dg-error "Fortran 2008: Semicolon at" } + ;; ! { dg-error "Fortran 2008: Semicolon at" } 900 ; ! { dg-error "Semicolon at" } end Index: gcc/testsuite/gfortran.dg/semicolon_free_2.f90 =================================================================== --- gcc/testsuite/gfortran.dg/semicolon_free_2.f90 (Revision 0) +++ gcc/testsuite/gfortran.dg/semicolon_free_2.f90 (Revision 0) @@ -0,0 +1,10 @@ +! { dg-do compile } +! { dg-options "-std=f2008" } +! PR 19259 Semicolon cannot start a line +x=1; y=1; +x=2;; +x=3; + ; ! OK +;; ! OK +111 ; ! { dg-error "Semicolon at" } +end Index: gcc/testsuite/gfortran.dg/semicolon_free.f90 =================================================================== --- gcc/testsuite/gfortran.dg/semicolon_free.f90 (Revision 161388) +++ gcc/testsuite/gfortran.dg/semicolon_free.f90 (Arbeitskopie) @@ -1,4 +1,5 @@ ! { dg-do compile } +! { dg-options "-std=f2003" } ! PR 19259 Semicolon cannot start a line x=1; y=1; x=2;;