From patchwork Thu May 23 08:19:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Eggleston X-Patchwork-Id: 1103900 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-501509-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=codethink.co.uk Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 458j8n4JNFz9s55 for ; Thu, 23 May 2019 18:19:30 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=SWtnKfo1AzXTvPhWYL5VrxYhI1sFO6xcG3sDLC5Vpn6M+DOUL3 v4I849+HdM1eWvzT/5j1gvET4JeZ+AttCLTg/5MsbjRGiaPEsQ7kWT74zcTnk+ww Be/7F94Os7eUTI5drRvBf0nwUF/eNTW+yEdvN4HYabseYec9E7UpRlomA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=Ox55525p6m/KOvOfVZAYPjzodMY=; b=Xr+EFHEg+aGJrDdV+l73 Vgnn2v7g+X5iThPg/mAEcg2JppCtweM7t5d1rLBTc24nBn+qaM1KRS8qL7tC1H/f Kdav2hJK1AUFubpAwtu6apaTENt7hfuf7Qr4oPKIEc+f8YF5OsUeO3ejTPxICRu8 jMotaXs/mawLG/+m6Bev7Os= Received: (qmail 86032 invoked by alias); 23 May 2019 08:19:23 -0000 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 Received: (qmail 86018 invoked by uid 89); 23 May 2019 08:19:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_COUK, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy=H*Ad:D*uk, privileges, H*Ad:D*co.uk, PROGRAM X-HELO: imap1.codethink.co.uk Received: from imap1.codethink.co.uk (HELO imap1.codethink.co.uk) (176.9.8.82) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 23 May 2019 08:19:20 +0000 Received: from [167.98.27.226] (helo=[10.35.6.54]) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1hTiwY-00018k-3x; Thu, 23 May 2019 09:19:18 +0100 To: fortran , gcc-patches From: Mark Eggleston Subject: [PATCH] PR fortran/89103 - Allow blank format items in format strings Message-ID: <48e1b516-f5ff-f437-c734-f8e6633dd467@codethink.co.uk> Date: Thu, 23 May 2019 09:19:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89103 see comment 4 Please can some one commit the attached patch for me as I do not have the privileges to do so. Change logs: gcc/fortran     Jim MacArthur      Mark Eggleston      PR fortran/89103     * gfortran.texi: Add -fdec-blank-format-item     * invoke.texi: Add to section on Commas in FORMAT specifications.     * io.c (check_format): At FMT_RPAREN goto finished if     -fdec-blank-format-item.     * lang.opt: Add new option.     * options.c (set_dec_flags): Add SET_BITFLAG for     flag_dec_format_defaults. gcc/testsuite     Jim MacArthur     Mark Eggleston     PR fortran/89103     * gfortran.dg/dec_format_empty_item_1.f: New test.     * gfortran.dg/dec_format_empty_item_2.f: New test.     * gfortran.dg/dec_format_empty_item_3.f: New test. From f04143dd423d2eda2ce206e42ae914374b273f82 Mon Sep 17 00:00:00 2001 From: Jim MacArthur Date: Thu, 4 Feb 2016 16:59:41 +0000 Subject: [PATCH 1/5] Allow blank format items in format strings This has to be written in a slightly verbose manner because GCC 7 defaults to building with -Werror=implicit-fallthrough which prevents us from just falling through to the default: case. Test written by: Francisco Redondo Marchena Use -fdec-blank-format-item to enable. Also enabled by -fdec. --- gcc/fortran/gfortran.texi | 7 ++++++- gcc/fortran/invoke.texi | 13 +++++++++---- gcc/fortran/io.c | 10 ++++++++++ gcc/fortran/lang.opt | 4 ++++ gcc/fortran/options.c | 1 + gcc/testsuite/gfortran.dg/dec_format_empty_item_1.f | 19 +++++++++++++++++++ gcc/testsuite/gfortran.dg/dec_format_empty_item_2.f | 19 +++++++++++++++++++ gcc/testsuite/gfortran.dg/dec_format_empty_item_3.f | 19 +++++++++++++++++++ 8 files changed, 87 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/dec_format_empty_item_1.f create mode 100644 gcc/testsuite/gfortran.dg/dec_format_empty_item_2.f create mode 100644 gcc/testsuite/gfortran.dg/dec_format_empty_item_3.f diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi index 0e6c57142cd..2d53202dd71 100644 --- a/gcc/fortran/gfortran.texi +++ b/gcc/fortran/gfortran.texi @@ -1761,11 +1761,16 @@ When omitted, the count is implicitly assumed to be one. To support legacy codes, GNU Fortran allows the comma separator to be omitted immediately before and after character string edit -descriptors in @code{FORMAT} statements. +descriptors in @code{FORMAT} statements. A comma with no following format +decriptor is permited if the @option{-fdec-blank-format-item} is given on +the command line. This is considered non-conforming code and is +discouraged. @smallexample PRINT 10, 2, 3 10 FORMAT ('FOO='I1' BAR='I2) + print 20, 5, 6 +20 FORMAT (I3, I3,) @end smallexample diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi index 63fce66a593..80804993522 100644 --- a/gcc/fortran/invoke.texi +++ b/gcc/fortran/invoke.texi @@ -119,10 +119,10 @@ by type. Explanations are in the following sections. @gccoptlist{-fall-intrinsics -fbackslash -fcray-pointer -fd-lines-as-code @gol -fd-lines-as-comments -fdec -fdec-structure -fdec-intrinsic-ints @gol -fdec-static -fdec-math -fdec-include -fdec-format-defaults @gol --fdefault-double-8 -fdefault-integer-8 -fdefault-real-8 -fdefault-real-10 @gol --fdefault-real-16 -fdollar-ok -ffixed-line-length-@var{n} @gol --ffixed-line-length-none -fpad-source -ffree-form @gol --ffree-line-length-@var{n} -ffree-line-length-none @gol +-fdec-blank-format-item -fdefault-double-8 -fdefault-integer-8 @gol +-fdefault-real-8 -fdefault-real-10 -fdefault-real-16 -fdollar-ok @gol +-ffixed-line-length-@var{n} -ffixed-line-length-none -fpad-source @gol +-ffree-form -ffree-line-length-@var{n} -ffree-line-length-none @gol -fimplicit-none -finteger-4-integer-8 -fmax-identifier-length @gol -fmodule-private -ffixed-form -fno-range-check -fopenacc -fopenmp @gol -freal-4-real-10 -freal-4-real-16 -freal-4-real-8 -freal-8-real-10 @gol @@ -288,6 +288,11 @@ be on a single line and can use line continuations. Enable format specifiers F, G and I to be used without width specifiers, default widths will be used instead. +@item -fdec-blank-format-item +@opindex @code{fdec-blank-format-item} +Enable a blank format item at the end of a format specification i.e. nothing +following the final comma. + @item -fdollar-ok @opindex @code{fdollar-ok} @cindex @code{$} diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index 80a0d7402d2..4d0de65be1a 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -756,6 +756,16 @@ format_item_1: error = unexpected_end; goto syntax; + case FMT_RPAREN: + /* Oracle allows a blank format item. */ + if (flag_dec_blank_format_item) + goto finished; + else + { + error = unexpected_element; + goto syntax; + } + default: error = unexpected_element; goto syntax; diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt index 26e82601b62..cc2eae238b9 100644 --- a/gcc/fortran/lang.opt +++ b/gcc/fortran/lang.opt @@ -440,6 +440,10 @@ fdec Fortran Var(flag_dec) Enable all DEC language extensions. +fdec-blank-format-item +Fortran Var(flag_dec_blank_format_item) +Enable the use of blank format items in format strings. + fdec-include Fortran Var(flag_dec_include) Enable legacy parsing of INCLUDE as statement. diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c index 9ba48dc8439..e32aa441822 100644 --- a/gcc/fortran/options.c +++ b/gcc/fortran/options.c @@ -75,6 +75,7 @@ set_dec_flags (int value) SET_BITFLAG (flag_dec_math, value, value); SET_BITFLAG (flag_dec_include, value, value); SET_BITFLAG (flag_dec_format_defaults, value, value); + SET_BITFLAG (flag_dec_blank_format_item, value, value); } /* Finalize DEC flags. */ diff --git a/gcc/testsuite/gfortran.dg/dec_format_empty_item_1.f b/gcc/testsuite/gfortran.dg/dec_format_empty_item_1.f new file mode 100644 index 00000000000..ed27c18944b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_format_empty_item_1.f @@ -0,0 +1,19 @@ +! { dg-do run } +! { dg-options "-fdec" } +! +! Test blank/empty format items in format string +! +! Test case contributed by Jim MacArthur +! Modified by Mark Eggleston +! + PROGRAM blank_format_items + INTEGER A/0/ + + OPEN(1, status="scratch") + WRITE(1, 10) 100 + REWIND(1) + READ(1, 10) A + IF (a.NE.100) STOP 1 + PRINT 10, A +10 FORMAT( I5,) + END diff --git a/gcc/testsuite/gfortran.dg/dec_format_empty_item_2.f b/gcc/testsuite/gfortran.dg/dec_format_empty_item_2.f new file mode 100644 index 00000000000..2793cb16225 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_format_empty_item_2.f @@ -0,0 +1,19 @@ +! { dg-do run } +! { dg-options "-fdec-blank-format-item" } +! +! Test blank/empty format items in format string +! +! Test case contributed by Jim MacArthur +! Modified by Mark Eggleston +! + PROGRAM blank_format_items + INTEGER A/0/ + + OPEN(1, status="scratch") + WRITE(1, 10) 100 + REWIND(1) + READ(1, 10) A + IF (a.NE.100) STOP 1 + PRINT 10, A +10 FORMAT( I5,) + END diff --git a/gcc/testsuite/gfortran.dg/dec_format_empty_item_3.f b/gcc/testsuite/gfortran.dg/dec_format_empty_item_3.f new file mode 100644 index 00000000000..499db922876 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_format_empty_item_3.f @@ -0,0 +1,19 @@ +! { dg-do compile } +! { dg-options "-fdec -fno-dec-blank-format-item" } +! +! Test blank/empty format items in format string +! +! Test case contributed by Jim MacArthur +! Modified by Mark Eggleston +! + PROGRAM blank_format_items + INTEGER A/0/ + + OPEN(1, status="scratch") + WRITE(1, 10) 100 ! { dg-error "FORMAT label 10 at \\(1\\) not defined" } + REWIND(1) + READ(1, 10) A ! { dg-error "FORMAT label 10 at \\(1\\) not defined" } + IF (a.NE.100) STOP 1 + PRINT 10, A ! { dg-error "FORMAT label 10 at \\(1\\) not defined" } +10 FORMAT( I5,) ! { dg-error "Unexpected element" } + END -- 2.11.0