From patchwork Tue Jun 20 10:50:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 110412 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3572707vqr; Tue, 20 Jun 2023 03:51:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ69mX9zMvFyv/3qf/AGVVBQEQcNh5yHs3XZQxZQ6qKF4aN+6q0uA9GrEarbENRfaPiJAfva X-Received: by 2002:a17:907:1ca8:b0:973:d076:67ab with SMTP id nb40-20020a1709071ca800b00973d07667abmr11416811ejc.42.1687258310844; Tue, 20 Jun 2023 03:51:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687258310; cv=none; d=google.com; s=arc-20160816; b=VVFj0ExW33+Bx8E2r4I7H2rr2UuTXq4A/eCmIZsGCXfGsRa3I8z23zxm0wpv7ORl7r uheNSQDTh/e5MyP8O9NvU2bbz2WNGQxia7+I0q75nheiHJBzJQPHXOc7WL/NaOwI7Sa8 Af9X4fkkQH+SkFkqtduZ2VDNGLayW+0bEFGFVqwqIyLJEJNcd3k/rXSfiXDlL2lHAcV4 Ar0QIdTbigSB2DvwkE9zFpiee8x9liYrjRgr++iAR2NbQ5ThVOU5pnanGHTEO3IepQOL LxLED18OrYG39hgbnUUTJo6MxjcalfC5PtA0U3PPhBAPhcDRCgOT2pj0+Y0ho2AJHf0X Mlbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:from:to :content-language:user-agent:mime-version:date:message-id :ironport-sdr:dmarc-filter:delivered-to; bh=kO0PZJbOYcz47O9dldrczOlEuNvfDwTpE6D1H00GXXg=; b=lFIEc1BUSbwZQFv9sjxhfsLTQAae6A/St6viNl0rOMdlHThm5dzgYWa5kVsK3GUe/E LJ+UsZNC4LqYZEmW9I6CbSKIHYeCI3+HPE1XleAZMIvR2E/PnyLiWxMXrFmV/1l4Hcs9 E9cas38mRLjiyJv6DNBfQYbRwq/Fai3OaA9BLmhSlw3rRY2cSL+C4/W7mNV2SsNySfVz XIl0qNg8xKkk4oVZxiXsXPTxEBc5NwK/SrJl7pRjTdxvvF7QLqOGKeE2O9gQzzkqwDuC 1ndGvPo4/o1OdVsByNbX8fnbl/ygZ2AIHYZN80P7rrkdg2x/T2hp88QxOz8YjDxuGzkS GVdA== ARC-Authentication-Results: i=1; mx.google.com; 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" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id qk12-20020a170906d9cc00b009659573b4e3si1032613ejb.51.2023.06.20.03.51.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 03:51:50 -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; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3F0DC385559B for ; Tue, 20 Jun 2023 10:51:11 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id E3E6B3858D1E; Tue, 20 Jun 2023 10:50:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E3E6B3858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="6.00,256,1681200000"; d="diff'?scan'208";a="10399804" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 20 Jun 2023 02:50:41 -0800 IronPort-SDR: GcOjihDAzsZtEkV+H10tyHfTjvH66tvOnS0bY75gWLV5j/uPd4cppXo5DDDTJF0n5P39NeDAwZ 5dM8VvnPX1GjFtUk4zLfcVRtEk/OFh9fVXRjKpVM2n3m7WpEW612qLVaXCgJU3u9yX+RZh2z7o E/5bQfj8rnUcj8cWPfMj9wJoIfKSwMktOwFiCV0t3/idERpK2Rk3lcIcnkuWIB4s4wPTJ6lYtK 0KrPRUaTsTwqqN1uJ1rcuqicPRSe4P3e8lyrcKe7IFY5V8U4PahZXS4YWg3nDL95aSa+rIntfv Mvc= Message-ID: <7e2f6b2d-b1e2-8aed-f9ea-11f5a72c5794@codesourcery.com> Date: Tue, 20 Jun 2023 12:50:36 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Content-Language: en-US To: gcc-patches , fortran From: Tobias Burnus Subject: [Patch] Fortran's gfc_match_char: %S to match symbol with host_assoc X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-15.mgc.mentorg.com (139.181.222.15) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, 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: , 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?1769218570529734865?= X-GMAIL-MSGID: =?utf-8?q?1769218570529734865?= When just matching a symbol, one can use 'gfc_match_symbol (&sym, host_assoc)' and has the option to match with and without host association. However, when matching something more complex via 'gfc_match' like "something ( %s ) , " the match uses host_assoc = false. While it can be combined ("something (" + symbol + " ) ,"), this requires keeping track of the previous location and resetting it. It seems to be much simply to add a new flag supporting host_assoc = true, which this patch does (using '%S'). The advantage is also that when looking at the comment or at the "%s" implementation, it is clear that there are two variants, making it less likely to choose the wrong matching. OK for mainline? Tobias PS: I will use it in an upcoming OpenMP to parse 'uses_allocators'. ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 Fortran's gfc_match_char: %S to match symbol with host_assoc gfc_match ("... %s ...", ...) matches a gfc_symbol but with host_assoc = 0. This commit adds '%S' as variant which matches with host_assoc = 1 gcc/fortran/ChangeLog: * match.cc (gfc_match_char): Match with '%S' a symbol with host_assoc = 1. diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc index e7be7fddc64..a350ebf754e 100644 --- a/gcc/fortran/match.cc +++ b/gcc/fortran/match.cc @@ -1084,7 +1084,8 @@ gfc_match_char (char c, bool gobble_ws) %% Literal percent sign %e Expression, pointer to a pointer is set - %s Symbol, pointer to the symbol is set + %s Symbol, pointer to the symbol is set (host_assoc = 0) + %S Symbol, pointer to the symbol is set (host_assoc = 1) %n Name, character buffer is set to name %t Matches end of statement. %o Matches an intrinsic operator, returned as an INTRINSIC enum. @@ -1151,8 +1152,9 @@ loop: goto loop; case 's': + case 'S': vp = va_arg (argp, void **); - n = gfc_match_symbol ((gfc_symbol **) vp, 0); + n = gfc_match_symbol ((gfc_symbol **) vp, c == 'S'); if (n != MATCH_YES) { m = n;