From patchwork Sun May 8 20:17:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 1628192 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=S0CWwaBe; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KxFwj25lFz9sGk for ; Mon, 9 May 2022 06:17:56 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 060A23857C4D for ; Sun, 8 May 2022 20:17:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 060A23857C4D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652041071; bh=puuXD1LynNhmwxcTpZohjG1CiQWNFAp2FjXmPJ8N9uY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=S0CWwaBeVzZeWUqAuYgr7wl/glMAxaVzps1ZV9T3ZNj/9a4jFesu3vK79GysKgNTv aqQZ3060iZAaTZtW+xvdDVdS4jO4iQkdPZ6nC9BOlrCBcwPEoyq/AZKvAOmz5iXuYU MeKasgAWWjHTz2PkrwbIyedgMVsIYIVGyJmKGPqQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by sourceware.org (Postfix) with ESMTPS id 2017D385840F; Sun, 8 May 2022 20:17:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2017D385840F X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [93.207.82.52] ([93.207.82.52]) by web-mail.gmx.net (3c-app-gmx-bs41.server.lan [172.19.170.93]) (via HTTP); Sun, 8 May 2022 22:17:11 +0200 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH] PR fortran/105501 - check for non-optional spaces between adjacent keywords Date: Sun, 8 May 2022 22:17:11 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:t3o3E2nZOB4snXm3IyrLWPVzm/Ux1MCkWH4+frb3vSrUY29WuBvCwtXl+8aOxj5E7LNOU QMOgkeWzWwPDyvA6hKaM9rB+r9O9WVhGPRiXoqB61XRsSJfKlpsaw5y8hM4O4UTHJjN9UlJiXy/7 alhjsURLUse9660d20C6n1/WgqGysWNighghk/Y1UxbElWK2s0CXj6nY9QkTpYiOBhYEhMFSe413 mYVUHvENBlbqA65+i8OpmWQ5fYZzaM2eM5wJ4tVrdD2E2Epd/a1MFXhqSZ/ppKxCl+yjOEGSBbsK 0w= X-UI-Out-Filterresults: notjunk:1;V03:K0:YOxtAvQAmzw=:301mOE064LhLuOZ43PW/Of t3LoLKe7bG3QbhKgWkY/boi36M6nLDid7yEwcMNYCcayquqY+QtflQHxCio+CkQ+Qgd56ZoFs yXyRBB6EvbhlBVN5bcXw66KQ9hyD8UBucNLSA5Mj3b2VQCHpiYgYz5Hb58wthwKUe4q0dT+Mc CUXz+NeHdJaBaanaTvKtcFdefh27cGZSw++D5JOFln9l7MT9v+8O3iFIw2hPTOMMZ8aEnb/Vs JN76lESi7Z7P0DpjjqXADv3xwjY+y2KK+nodHIlbEObMliFOci4/O1a/RXIj1HIVoAqtJCshz /hVoHonW0lIU2L0uiHGeMYORpIckF8GqP9BgDbUxk4ERMJcYyo3P3P84boJ5wDXPK3mjG65CP Yz7AUG6N81G5ZK27V8AXNmQ/UvDm+ixUfwmUWoYfG2tjXAabEftqZ1HWfYgf3Z50iRSp6t8HP NX04tux+MUhxKD9mQAGjSNvNAzfhdOgoB98FRAOTwwT4ADQ17HiRwDWLv0jQuaGGlVPNjdwNk Ho6vArtXsiZp+NTywy+q44if2xh3Sn5hfPPv5Jv2uXHQe0jfPHMAtsMQbckqtiD3Zl2Od63W/ HUDl/H00rDKt5iJIE6hM6JvqMZ8VXMxGHPrSyf0BeVj50hKpR494EANZxHZ1w8raJYiPgxxO2 Hbkurqbkgkg9tMExeqK49Wdb+Uzk+0HWh2t2OniiSk0UZfuS5eWwgG6wSF/JBWe87QqAPaXr8 vTEt4L8v42wqE31J3Ejb/6ANYQnYeJ+DijKye0QrgKZxtCAkqtLC9Fbsr5W8pDPiX2mBB/8m+ 1aaij7u X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Harald Anlauf via Gcc-patches From: Harald Anlauf Reply-To: Harald Anlauf Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Dear all, the PR correctly notes that a space between keywords 'TYPE' and 'IS' is required in free-form, but we currently accept 'TYPEIS'. We shouldn't. The combinations with non-optional blanks are listed in the standard; in F2018 this is table 6.2. While at it, I saw a couple of other keyword combinations in the matcher and fixed these too. I cross-checked my findings with Intel, Crayftn, and NAG (as far as possible). Regarding the testcase: I do not know how to write a (single!) testcase that is able to check multiple of those fixes. I also do not think that it makes sense to provide a testcase for each single fixed pattern. Therefore a provided a single, minimal testcase based on the report. Regtested on x86_64-pc-linux-gnu. OK for mainline (i.e. 13-master)? Thanks, Harald From 8b04cb084e138966cf20187887da676ad9e4a00e Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Sun, 8 May 2022 22:04:27 +0200 Subject: [PATCH] Fortran: check for non-optional spaces between adjacent keywords In free format, spaces between adjacent keywords are not optional except when a combination is explicitly listed (e.g. F2018: table 6.2). The following combinations thus require separating blanks: CHANGE TEAM, ERROR STOP, EVENT POST, EVENT WAIT, FAIL IMAGE, FORM TEAM, SELECT RANK, SYNC ALL, SYNC IMAGES, SYNC MEMORY, SYNC TEAM, TYPE IS. gcc/fortran/ChangeLog: PR fortran/105501 * match.cc (gfc_match_if): Adjust patterns used for matching. (gfc_match_select_rank): Likewise. * parse.cc (decode_statement): Likewise. gcc/testsuite/ChangeLog: PR fortran/105501 * gfortran.dg/pr105501.f90: New test. --- gcc/fortran/match.cc | 22 +++++++++++----------- gcc/fortran/parse.cc | 22 +++++++++++----------- gcc/testsuite/gfortran.dg/pr105501.f90 | 15 +++++++++++++++ 3 files changed, 37 insertions(+), 22 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr105501.f90 diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc index 205811bb969..1aa3053e70e 100644 --- a/gcc/fortran/match.cc +++ b/gcc/fortran/match.cc @@ -1606,21 +1606,21 @@ gfc_match_if (gfc_statement *if_type) match ("assign", gfc_match_assign, ST_LABEL_ASSIGNMENT) match ("backspace", gfc_match_backspace, ST_BACKSPACE) match ("call", gfc_match_call, ST_CALL) - match ("change team", gfc_match_change_team, ST_CHANGE_TEAM) + match ("change% team", gfc_match_change_team, ST_CHANGE_TEAM) match ("close", gfc_match_close, ST_CLOSE) match ("continue", gfc_match_continue, ST_CONTINUE) match ("cycle", gfc_match_cycle, ST_CYCLE) match ("deallocate", gfc_match_deallocate, ST_DEALLOCATE) match ("end file", gfc_match_endfile, ST_END_FILE) match ("end team", gfc_match_end_team, ST_END_TEAM) - match ("error stop", gfc_match_error_stop, ST_ERROR_STOP) - match ("event post", gfc_match_event_post, ST_EVENT_POST) - match ("event wait", gfc_match_event_wait, ST_EVENT_WAIT) + match ("error% stop", gfc_match_error_stop, ST_ERROR_STOP) + match ("event% post", gfc_match_event_post, ST_EVENT_POST) + match ("event% wait", gfc_match_event_wait, ST_EVENT_WAIT) match ("exit", gfc_match_exit, ST_EXIT) - match ("fail image", gfc_match_fail_image, ST_FAIL_IMAGE) + match ("fail% image", gfc_match_fail_image, ST_FAIL_IMAGE) match ("flush", gfc_match_flush, ST_FLUSH) match ("forall", match_simple_forall, ST_FORALL) - match ("form team", gfc_match_form_team, ST_FORM_TEAM) + match ("form% team", gfc_match_form_team, ST_FORM_TEAM) match ("go to", gfc_match_goto, ST_GOTO) match ("if", match_arithmetic_if, ST_ARITHMETIC_IF) match ("inquire", gfc_match_inquire, ST_INQUIRE) @@ -1634,10 +1634,10 @@ gfc_match_if (gfc_statement *if_type) match ("rewind", gfc_match_rewind, ST_REWIND) match ("stop", gfc_match_stop, ST_STOP) match ("wait", gfc_match_wait, ST_WAIT) - match ("sync all", gfc_match_sync_all, ST_SYNC_CALL); - match ("sync images", gfc_match_sync_images, ST_SYNC_IMAGES); - match ("sync memory", gfc_match_sync_memory, ST_SYNC_MEMORY); - match ("sync team", gfc_match_sync_team, ST_SYNC_TEAM) + match ("sync% all", gfc_match_sync_all, ST_SYNC_CALL); + match ("sync% images", gfc_match_sync_images, ST_SYNC_IMAGES); + match ("sync% memory", gfc_match_sync_memory, ST_SYNC_MEMORY); + match ("sync% team", gfc_match_sync_team, ST_SYNC_TEAM) match ("unlock", gfc_match_unlock, ST_UNLOCK) match ("where", match_simple_where, ST_WHERE) match ("write", gfc_match_write, ST_WRITE) @@ -6716,7 +6716,7 @@ gfc_match_select_rank (void) if (m == MATCH_ERROR) return m; - m = gfc_match (" select rank ( "); + m = gfc_match (" select% rank ( "); if (m != MATCH_YES) return m; diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc index e6e915d2a5e..7356d1b5a3a 100644 --- a/gcc/fortran/parse.cc +++ b/gcc/fortran/parse.cc @@ -454,7 +454,7 @@ decode_statement (void) case 'c': match ("call", gfc_match_call, ST_CALL); - match ("change team", gfc_match_change_team, ST_CHANGE_TEAM); + match ("change% team", gfc_match_change_team, ST_CHANGE_TEAM); match ("close", gfc_match_close, ST_CLOSE); match ("continue", gfc_match_continue, ST_CONTINUE); match ("contiguous", gfc_match_contiguous, ST_ATTR_DECL); @@ -479,7 +479,7 @@ decode_statement (void) match ("else", gfc_match_else, ST_ELSE); match ("else where", gfc_match_elsewhere, ST_ELSEWHERE); match ("else if", gfc_match_elseif, ST_ELSEIF); - match ("error stop", gfc_match_error_stop, ST_ERROR_STOP); + match ("error% stop", gfc_match_error_stop, ST_ERROR_STOP); match ("enum , bind ( c )", gfc_match_enum, ST_ENUM); if (gfc_match_end (&st) == MATCH_YES) @@ -488,15 +488,15 @@ decode_statement (void) match ("entry% ", gfc_match_entry, ST_ENTRY); match ("equivalence", gfc_match_equivalence, ST_EQUIVALENCE); match ("external", gfc_match_external, ST_ATTR_DECL); - match ("event post", gfc_match_event_post, ST_EVENT_POST); - match ("event wait", gfc_match_event_wait, ST_EVENT_WAIT); + match ("event% post", gfc_match_event_post, ST_EVENT_POST); + match ("event% wait", gfc_match_event_wait, ST_EVENT_WAIT); break; case 'f': - match ("fail image", gfc_match_fail_image, ST_FAIL_IMAGE); + match ("fail% image", gfc_match_fail_image, ST_FAIL_IMAGE); match ("final", gfc_match_final_decl, ST_FINAL); match ("flush", gfc_match_flush, ST_FLUSH); - match ("form team", gfc_match_form_team, ST_FORM_TEAM); + match ("form% team", gfc_match_form_team, ST_FORM_TEAM); match ("format", gfc_match_format, ST_FORMAT); break; @@ -562,16 +562,16 @@ decode_statement (void) match ("save", gfc_match_save, ST_ATTR_DECL); match ("static", gfc_match_static, ST_ATTR_DECL); match ("submodule", gfc_match_submodule, ST_SUBMODULE); - match ("sync all", gfc_match_sync_all, ST_SYNC_ALL); - match ("sync images", gfc_match_sync_images, ST_SYNC_IMAGES); - match ("sync memory", gfc_match_sync_memory, ST_SYNC_MEMORY); - match ("sync team", gfc_match_sync_team, ST_SYNC_TEAM); + match ("sync% all", gfc_match_sync_all, ST_SYNC_ALL); + match ("sync% images", gfc_match_sync_images, ST_SYNC_IMAGES); + match ("sync% memory", gfc_match_sync_memory, ST_SYNC_MEMORY); + match ("sync% team", gfc_match_sync_team, ST_SYNC_TEAM); break; case 't': match ("target", gfc_match_target, ST_ATTR_DECL); match ("type", gfc_match_derived_decl, ST_DERIVED_DECL); - match ("type is", gfc_match_type_is, ST_TYPE_IS); + match ("type% is", gfc_match_type_is, ST_TYPE_IS); break; case 'u': diff --git a/gcc/testsuite/gfortran.dg/pr105501.f90 b/gcc/testsuite/gfortran.dg/pr105501.f90 new file mode 100644 index 00000000000..85492e2d41c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr105501.f90 @@ -0,0 +1,15 @@ +! { dg-do compile } +! PR fortran/105501 - check for non-optional spaces between adjacent keywords + +MODULE M + TYPE T + INTEGER I + END TYPE +CONTAINS + SUBROUTINE S(X) + CLASS(T), POINTER :: X + SELECTTYPE (X) ! blank between SELECT and TYPE is optional + TYPEIS (T) ! { dg-error "Mangled derived type definition" } + END SELECT + END SUBROUTINE +END MODULE -- 2.35.3