From patchwork Thu Oct 31 22:16:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 1187687 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-512202-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=troutmask.apl.washington.edu Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Vm/whBJU"; dkim-atps=neutral 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 47405q6wFBz9sR6 for ; Fri, 1 Nov 2019 09:16:13 +1100 (AEDT) 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=KbrinH5+NY1fXxsB1eW3hWAzTxkwozlBMLxHVlkV5p3 B9LoH+Vn4acjKhXDMBQrXo+2XirMVjdfJ/pCncZG6Q1dZotKdUTOBV6GBbnmxTi5 R+BVcu8CvkgKAZQ3PxSLw2f2d3q72dVJUFUB0OlJ4G8JABd8iA8GbJhR3Q/XXD0c = 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=hxmvU8cNXdsUB9VGNwltlt9T/GI=; b=Vm/whBJUP3cJGdKhx tcC+oS1uAnqQ0DmkvTTa0O4w481C/5lWoOGIKpVQoVxvmvuT/ihlRyj6iMYdbfeD B4Itk15EEMyWpv9VCxb7ytohEs7XAi7hD50aCO8bGL1Afcy4n/DdQ5177zYIAOpo dTgVY9cDWrqHgd7fMjsvnG6kAA= Received: (qmail 117833 invoked by alias); 31 Oct 2019 22:16:06 -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 117816 invoked by uid 89); 31 Oct 2019 22:16:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT autolearn=ham version=3.3.1 spammy=Steven, steven, sk:gfc_mat, HX-Languages-Length:2748 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; Thu, 31 Oct 2019 22:16:04 +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 x9VMG3Aa013732 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Thu, 31 Oct 2019 15:16:03 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id x9VMG2cQ013731; Thu, 31 Oct 2019 15:16:02 -0700 (PDT) (envelope-from sgk) Date: Thu, 31 Oct 2019 15:16:02 -0700 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] Fix the fix for PR fortran/90988 Message-ID: <20191031221602.GA13698@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.12.2 (2019-09-21) Jeff Law sent me an email that showed my patch for PR fortran/90988 caused a regression for fixed-form source code. The attached patch address that regression. Briefly, the original patch fixed free-form souce code parsing for 'PUBLICX' where the required whitespace was missing (i.e., 'PUBLIC X'). Unfortunately, the regression is that the original fix did not preserve fixed-form source code. OK to commit? 2019-10-31 Steven G. Kargl PR fortran/90988 * decl.c (gfc_match_private, gfc_match_public): Fixed-form source code does not require whitespace between PRIVATE (or PUBLIC) and an entity. 2019-10-31 Steven G. Kargl PR fortran/90988 * gfortran.dg/pr90988_4.f: New test. Index: gcc/fortran/decl.c =================================================================== --- gcc/fortran/decl.c (revision 277696) +++ gcc/fortran/decl.c (working copy) @@ -9059,7 +9079,6 @@ match gfc_match_private (gfc_statement *st) { gfc_state_data *prev; - char c; if (gfc_match ("private") != MATCH_YES) return MATCH_NO; @@ -9083,10 +9102,14 @@ gfc_match_private (gfc_statement *st) return MATCH_YES; } - /* At this point, PRIVATE must be followed by whitespace or ::. */ - c = gfc_peek_ascii_char (); - if (!gfc_is_whitespace (c) && c != ':') - return MATCH_NO; + /* At this point in free-form source code, PRIVATE must be followed + by whitespace or ::. */ + if (gfc_current_form == FORM_FREE) + { + char c = gfc_peek_ascii_char (); + if (!gfc_is_whitespace (c) && c != ':') + return MATCH_NO; + } prev = gfc_state_stack->previous; if (gfc_current_state () != COMP_MODULE @@ -9108,8 +9131,6 @@ gfc_match_private (gfc_statement *st) match gfc_match_public (gfc_statement *st) { - char c; - if (gfc_match ("public") != MATCH_YES) return MATCH_NO; @@ -9127,10 +9148,14 @@ gfc_match_public (gfc_statement *st) return MATCH_YES; } - /* At this point, PUBLIC must be followed by whitespace or ::. */ - c = gfc_peek_ascii_char (); - if (!gfc_is_whitespace (c) && c != ':') - return MATCH_NO; + /* At this point in free-form source code, PUBLIC must be followed + by whitespace or ::. */ + if (gfc_current_form == FORM_FREE) + { + char c = gfc_peek_ascii_char (); + if (!gfc_is_whitespace (c) && c != ':') + return MATCH_NO; + } if (gfc_current_state () != COMP_MODULE) { Index: gcc/testsuite/gfortran.dg/pr90988_4.f =================================================================== --- gcc/testsuite/gfortran.dg/pr90988_4.f (nonexistent) +++ gcc/testsuite/gfortran.dg/pr90988_4.f (working copy) @@ -0,0 +1,10 @@ +c { dg-do compile } + module foo + implicit none + real a,b,c + integer i,j,k + public a,b + publicc + private i,j + privatek + end module foo