From patchwork Thu Jun 1 19:05:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 102141 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp552045vqr; Thu, 1 Jun 2023 12:06:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4NGEdy0lkAePnhRrySfMHiXLH0sxReVJ9Akfxunm23Vjjy85qv3rKbtr/2uVlzaGk4iB2p X-Received: by 2002:aa7:cd51:0:b0:514:9e81:9067 with SMTP id v17-20020aa7cd51000000b005149e819067mr599778edw.12.1685646367766; Thu, 01 Jun 2023 12:06:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685646367; cv=none; d=google.com; s=arc-20160816; b=xKjhKycKrcH/RYdOhHIXfB3hWFZqiKPJkJOHcaIg+l2g+qE1deOCCNNBZhVqlS5G7A gOrdJ600hpIJry1rgKQGS9qpqCjfM7dSPuK/Lv1+eahHCubxqXlHN1wCvdA5aygvCKTT lZsFkx29AsY+6A0B9UKknfZZizIGvL+FHjrFRzhe+NmpkDoFGsiLnnIR+VUp61dA/O+e S8IQ9NFNGM6WFdI2JVtzKjfgfr9TQihHMTGh785ywvN6YfEINFmrMCajFzvfz++hjBWy 18hkkQF8GdX7sB2lwgF8ob+wotuckTsU+zDCHjBZaq/8cxkcN02Sml6LUv/UvuAAXJ7h 0B3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:ui-outboundreport :sensitivity:importance:date:subject:to:message-id:mime-version :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=JPBx8Y7a/4E6jkcSlUap1REQCt1oQEkcm5Ur+p2Gyec=; b=ddAzRTkuiK9GgToovSk7HrXdgduPPvMeCd7xbaaoEKg4O9+62OO3ZTxJ2T+bHyuyIr RgP243EFEIJImGlrjb60YmSXD++drYJ6VsKUTkHzafLvonUDRuDfwkBvCU8fCXV1m0S6 Yf8XDAAxMRRFFygA3DbrsPxeD+2gjpWXv0zprpjOf/5nspeh9pNjPABXAVwIvtuF8Wig DjJ97kM4GwmE/vlJG+9FplvKQ1kXzwKqynIL8kq65KoLnU3P/hfMAn3hsffP8f8G9qLA SJ8eXodrPV1qfny15tooeoxAlSrvV1IniIX6/am6AZmrtd9DdahlWHe9I4MJCw7dcRnX yn4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=YxeIwzFl; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id b4-20020aa7d484000000b00514a680cac4si5293520edr.548.2023.06.01.12.06.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 12:06:07 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=YxeIwzFl; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A96DF3857357 for ; Thu, 1 Jun 2023 19:06:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A96DF3857357 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685646366; bh=JPBx8Y7a/4E6jkcSlUap1REQCt1oQEkcm5Ur+p2Gyec=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=YxeIwzFlREeMjKoeLUxymci+cV/Byuze0ze2385Uj/SMbEvP9aYmCQv3o986Sp6u0 YSEqYNdeIjieBAoZtIO+nFvRNysMi4e/qr9rFJVGyYpk3PPM+ed2qd7vI8tBbTV0C1 8MmaYA8uyOr/vDJsDxHoH4Xd252PC5U/GoH/Sz9I= 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.20]) by sourceware.org (Postfix) with ESMTPS id BDD2D3857031; Thu, 1 Jun 2023 19:05:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BDD2D3857031 X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [79.251.3.90] ([79.251.3.90]) by web-mail.gmx.net (3c-app-gmx-bap24.server.lan [172.19.172.94]) (via HTTP); Thu, 1 Jun 2023 21:05:10 +0200 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH] Fortran: force error on bad KIND specifier [PR88552] Date: Thu, 1 Jun 2023 21:05:10 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:yWbl3+0jyPegu6tYOkuq4OEgyBbgvVgLhdMO6RsvTLun0SeMCyw613oL/1Gzxvy+R71uQ bvKQuYg3k+RAbqgbqfG9FymDNsgrDP7dS+U2Gj+WTw3Z2YjtaH4uEMEjdqoDg6/CmkjwS3I3ggRp Lr++V6ddINelKeWF0vOgJ2mhnIhSSa7gkMkyqAeva3S+FKwykO+pT32xBZuBKuXyJT+3BC+jI3uE hcDC92KCkbxmlrzUxabO/L7hDa6dIhpfNzAgQ8Yx1L9rWlH9zebMDOU+jBM4soDQulEgZKonhDGw lA= UI-OutboundReport: notjunk:1;M01:P0:Vj3z5Vz3EwM=;9yX27toha8Rk1ni1feaqDPtFUxV Aq1ZDyLIWlSxjOjphJLzzQH6ChNHf6/2zZ66+ki09v6rLnU85vLngNWtSxHlYyNF4LzThCA/F RoOZTc2l4QQpsuYikqKp2upoeLsgNBeCN/mQTnt98hvf3gKRTme5selPOfPlQ7Qo0JaqVuW3F GGKlTWaVkAcp3NeE9uRXDphHMrygnd/ZrW5w0cZVK01u/nz1jJTw27LuVV3qrx1TMbykTwHZE /XemFNVg7xYSF4CtgnKoTYLo04OiwJu2h++BefNPawME65Ir8fWt4pqITWz5CDSIjvLCqAsdv IhCA2V4VoLbaRDrkU2jPV7694A2dEmb5p4xvJSV9l0LTD+l26iY6u7LvQYQK++4ybKX9TD6P6 dHnJKbp54IjOhw/dD7gJ9sdJjyA3/IgRpJqNIfRV0671KU0d7okVoETb5/H3EuXQb5J/0Jlxm 30z3UIHgLrZRKjVM6xMbSSv81+E9+EXzfide+yu4Q4w5XZSBFvKmp+a2VZi54rtp544WfcQW9 EoBxXNTGneR4qJdlOGlIrrYeLAnCE4g7g9d0BsXNf1/eWku5kEp3z/e1SO6W5GJUfu9tuRhQe 5Us0Mg0rlicTxAyA41V5ap7cJGidcKHOq3K2CSn2+2Y7vdppLDWe+4CVtdzhyJuU7IQb53my6 3ZSDR32lZH7qpjaXWiwSJazj69IocboJock6FhQkkDruZHYUOsP+b+MCpMjlvAymkObo5l18u b4lPjORMJX0W7JAlRir6XGtShg+CwziwnXwvb+c4aYi2SfwdF7hxO0edF6lJV9hn7RjYYlKto lAHusHQl1UNt+iQZO5QT0TjHNShA8nK1BFZ7O5Z2EeM2A= X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767528326085159354?= X-GMAIL-MSGID: =?utf-8?q?1767528326085159354?= Dear all, we sometimes silently accept wrong declarations with unbalanced parentheses, as the PR and testcases therein show. It appears that the fix is obvious: use the existing error paths in gfc_match_kind_spec and error return from gfc_match_decl_type_spec. I'm still posting it here in case I have missed something not so obvious. The patch regtests cleanly on x86_64-pc-linux-gnu. OK for mainline? Thanks, Harald From a30ff5af130c4d33c086fd136978d5f49cb8bde4 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Thu, 1 Jun 2023 20:56:11 +0200 Subject: [PATCH] Fortran: force error on bad KIND specifier [PR88552] gcc/fortran/ChangeLog: PR fortran/88552 * decl.cc (gfc_match_kind_spec): Use error path on missing right parenthesis. (gfc_match_decl_type_spec): Use error return when an error occurred during matching a KIND specifier. gcc/testsuite/ChangeLog: PR fortran/88552 * gfortran.dg/pr88552.f90: New test. --- gcc/fortran/decl.cc | 4 ++++ gcc/testsuite/gfortran.dg/pr88552.f90 | 6 ++++++ 2 files changed, 10 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr88552.f90 diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc index 1de2b231242..deb20647fb9 100644 --- a/gcc/fortran/decl.cc +++ b/gcc/fortran/decl.cc @@ -3366,6 +3366,7 @@ close_brackets: else gfc_error ("Missing right parenthesis at %C"); m = MATCH_ERROR; + goto no_match; } else /* All tests passed. */ @@ -4716,6 +4717,9 @@ get_kind: return MATCH_ERROR; } + if (m == MATCH_ERROR) + return MATCH_ERROR; + /* Defer association of the KIND expression of function results until after USE and IMPORT statements. */ if ((gfc_current_state () == COMP_NONE && gfc_error_flag_test ()) diff --git a/gcc/testsuite/gfortran.dg/pr88552.f90 b/gcc/testsuite/gfortran.dg/pr88552.f90 new file mode 100644 index 00000000000..15e1b372f8f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr88552.f90 @@ -0,0 +1,6 @@ +! { dg-do compile } +! PR fortran/88552 +! Contributed by G.Steinmetz + +integer(len((c)) :: n ! { dg-error "must be CHARACTER" } +end -- 2.35.3