From patchwork Wed Nov 16 21:37:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 82617 Delivered-To: patch@linaro.org Received: by 10.182.1.168 with SMTP id 8csp478359obn; Wed, 16 Nov 2016 13:38:00 -0800 (PST) X-Received: by 10.99.146.76 with SMTP id s12mr12780077pgn.8.1479332280753; Wed, 16 Nov 2016 13:38:00 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id w3si33522508pgo.321.2016.11.16.13.38.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Nov 2016 13:38:00 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-441732-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-441732-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-441732-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=ABEbv/JLRnKqvBYTRkKu4PCGSBmOGvRSKQcQFt/NXzv oQiaBfAYx68EUCx1a7KIc17qYD3uX1Uf2BZPWC2zN5A2PmHu3qDkG4ShvUOYev2P 0raZ/HquB/QnYzwrHlfFCf99RsGDBUss0JbaURN7ozJp0+mqqOq1i2Nuu702VF4c = 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:date :from:to:subject:message-id:reply-to:mime-version:content-type; s=default; bh=dp0J/vMGx+fqVKix/rVAhWknG6E=; b=bt0k0l61vDsYeQgAJ xG9MDxi7EJpzz04iaYgo4IgHwOLckl4g5yhoCnyQxynD4G8GbcEMgHJSHIcdL13+ vtt/0wIeBZdlcYn8EpKDtOjR5B81pLW9AVdKdYDBixrJ+Wj+xEC8CAWAEd8yE0zv fXeu9sqwqKfC7fKDT/2qxxPV7o= Received: (qmail 56826 invoked by alias); 16 Nov 2016 21:37:40 -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 56805 invoked by uid 89); 16 Nov 2016 21:37:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=FORMAT, Tab, 2537, 284, 7 X-Spam-User: qpsmtpd, 2 recipients X-HELO: troutmask.apl.washington.edu Received: from troutmask.apl.washington.edu (HELO troutmask.apl.washington.edu) (128.95.76.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 16 Nov 2016 21:37:29 +0000 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id uAGLbRP0067320 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 16 Nov 2016 13:37:27 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id uAGLbQp7067319; Wed, 16 Nov 2016 13:37:26 -0800 (PST) (envelope-from sgk) Date: Wed, 16 Nov 2016 13:37:26 -0800 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] PR fortran/58001 -- Handle tab in FORMAT Message-ID: <20161116213726.GA67287@troutmask.apl.washington.edu> Reply-To: kargl@uw.edu MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.6.1 (2016-04-27) An earlier version of the attached patch lingered in bugzilla for over 3 years. I've updated the patch to include Manuel's comment #12. Regression tested on x86_64-*-freebsd. OK to commit? 2016-11-16 Steven G. Kargl PR fortran/58001 * io.c (next_char_not_space): Update handling of a 'tab' in a FORMAT. (format_lex): Adjust invocations of next_char_not_space(). 2016-11-16 Steven G. Kargl PR fortran/58001 * gfortran.dg/fmt_tab_1.f90: Adjust testcase. * gfortran.dg/fmt_tab_2.f90: Ditto. -- Steve Index: gcc/fortran/io.c =================================================================== --- gcc/fortran/io.c (revision 242512) +++ gcc/fortran/io.c (working copy) @@ -200,23 +200,14 @@ unget_char (void) /* Eat up the spaces and return a character. */ static char -next_char_not_space (bool *error) +next_char_not_space () { char c; do { error_element = c = next_char (NONSTRING); if (c == '\t') - { - if (gfc_option.allow_std & GFC_STD_GNU) - gfc_warning (0, "Extension: Tab character in format at %C"); - else - { - gfc_error ("Extension: Tab character in format at %C"); - *error = true; - return c; - } - } + gfc_warning (OPT_Wtabs, "Nonconforming tab character in format at %C"); } while (gfc_is_whitespace (c)); return c; @@ -234,7 +225,6 @@ format_lex (void) char c, delim; int zflag; int negative_flag; - bool error = false; if (saved_token != FMT_NONE) { @@ -243,7 +233,7 @@ format_lex (void) return token; } - c = next_char_not_space (&error); + c = next_char_not_space (); negative_flag = 0; switch (c) @@ -253,7 +243,7 @@ format_lex (void) /* Falls through. */ case '+': - c = next_char_not_space (&error); + c = next_char_not_space (); if (!ISDIGIT (c)) { token = FMT_UNKNOWN; @@ -264,7 +254,7 @@ format_lex (void) do { - c = next_char_not_space (&error); + c = next_char_not_space (); if (ISDIGIT (c)) value = 10 * value + c - '0'; } @@ -294,7 +284,7 @@ format_lex (void) do { - c = next_char_not_space (&error); + c = next_char_not_space (); if (ISDIGIT (c)) { value = 10 * value + c - '0'; @@ -329,7 +319,7 @@ format_lex (void) break; case 'T': - c = next_char_not_space (&error); + c = next_char_not_space (); switch (c) { case 'L': @@ -357,7 +347,7 @@ format_lex (void) break; case 'S': - c = next_char_not_space (&error); + c = next_char_not_space (); if (c != 'P' && c != 'S') unget_char (); @@ -365,7 +355,7 @@ format_lex (void) break; case 'B': - c = next_char_not_space (&error); + c = next_char_not_space (); if (c == 'N' || c == 'Z') token = FMT_BLANK; else @@ -427,7 +417,7 @@ format_lex (void) break; case 'E': - c = next_char_not_space (&error); + c = next_char_not_space (); if (c == 'N' ) token = FMT_EN; else if (c == 'S') @@ -457,7 +447,7 @@ format_lex (void) break; case 'D': - c = next_char_not_space (&error); + c = next_char_not_space (); if (c == 'P') { if (!gfc_notify_std (GFC_STD_F2003, "DP format " @@ -478,7 +468,7 @@ format_lex (void) "specifier not allowed at %C")) return FMT_ERROR; token = FMT_DT; - c = next_char_not_space (&error); + c = next_char_not_space (); if (c == '\'' || c == '"') { delim = c; @@ -518,7 +508,7 @@ format_lex (void) break; case 'R': - c = next_char_not_space (&error); + c = next_char_not_space (); switch (c) { case 'C': @@ -559,9 +549,6 @@ format_lex (void) break; } - if (error) - return FMT_ERROR; - return token; } Index: gcc/testsuite/gfortran.dg/fmt_tab_1.f90 =================================================================== --- gcc/testsuite/gfortran.dg/fmt_tab_1.f90 (revision 242512) +++ gcc/testsuite/gfortran.dg/fmt_tab_1.f90 (working copy) @@ -1,7 +1,12 @@ ! { dg-do compile } -! { dg-options -Wno-error=tabs } +! { dg-options -Wtabs } ! PR fortran/32987 +! PR fortran/58001 program TestFormat write (*, 10) - 10 format ('Hello ', 'bug!') ! { dg-warning "Extension: Tab character in format" } + ! There is a tab character before 'bug!'. This is accepted without + ! the -Wno-tabs option or a -std= option. + 10 format ('Hello ', 'bug!') ! { dg-warning "tab character in format" } + end +! { dg-excess-errors "tab character in format" } Index: gcc/testsuite/gfortran.dg/fmt_tab_2.f90 =================================================================== --- gcc/testsuite/gfortran.dg/fmt_tab_2.f90 (revision 242512) +++ gcc/testsuite/gfortran.dg/fmt_tab_2.f90 (working copy) @@ -1,7 +1,9 @@ ! { dg-do compile } ! { dg-options "-std=f2003" } ! PR fortran/32987 +! PR fortran/58001 program TestFormat - write (*, 10) ! { dg-error "FORMAT label 10 at .1. not defined" } - 10 format ('Hello ', 'bug!') ! { dg-error "Extension: Tab character in format|Nonconforming tab character" } + write (*, 10) + 10 format ('Hello ', 'bug!') ! { dg-warning "tab character in format" } end +! { dg-excess-errors "tab character in FORMAT" }