From patchwork Wed Feb 7 11:43:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 197897 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2200013dyb; Wed, 7 Feb 2024 04:46:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IFlyFg/VTbQDatVRMPZCPNo0JQJtasCatz8o/HG67ed/b3dMjwDTMLnCyP0KIo2y0+YD74O X-Received: by 2002:a05:620a:2043:b0:783:df48:1b04 with SMTP id d3-20020a05620a204300b00783df481b04mr4486475qka.17.1707309959940; Wed, 07 Feb 2024 04:45:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707309959; cv=pass; d=google.com; s=arc-20160816; b=j7PBwomwQpUdu1WkppCbx16UL6tFxpLAmb5brBAjN9wt19uX+VovZ3Ly8ubEMp13Td HEuLDO+v1gyZFuZB2KSUjbQ+6gRV465dQQ/iO4xMqNRZzmdkfX9D4dah9V75WcPJvYMr xdSHy2gNeBUtqn7aJL2JSGI38lNEwgnaSD98IswQ395ovr6X15/q3GGs89B5WjN0UQsM U3tN2fD0OFMRym0AVezTRgcnjGdLOAJRMpgzYnb7ZJTx6GdUl7+nVHFH5BJ0Ymq+MUSd De+k0iyICNx+W0MgMerhn9E2escfzmQlOPMbOYM07B1kQ6XZaViwDI+7UXZOtN4dLm2W DqKg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=/fNGjZZmxhwFlkSqq00nmBtJDdnKifsuatlSnq1lGh4=; fh=cW5rutfYu7dKvMIx0ieX0wQ585sohBUenEXAcIjgtgc=; b=F6mO/e1KM1cpLJnBTjixXVMgpgOWnWSijS4DUADFSYXrwEAXYQu14EXKBUu7Vv6G/g ClrlEvJADS7U9F0flfk8pbsx+IrJio367B5bVqTvrCiTDuvtBppX63p4K3YE01AvH8ob BZf/zgw/2Iorn1NQ9gG3nWazZySBjhiyJIMsuD7fbQsEAnH9hEkVqGzFr9EOyQJE0OkU tpShEJjlht2Ph7bIKUjxS3UUqvQg5dF/cxM6eYHZZRZXWkUUI+ccV4ru2AqH3wuzg3d7 ebDJvsQu3aGXxeo8Dssn/rimS8LLsYVDoS4WecNHCssNjkolDbyeUPnaoqJmxGFdXQ4+ kbfw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=PnK+QKD+; arc=pass (i=1); 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" X-Forwarded-Encrypted: i=2; AJvYcCXzM9JgCE0qShpzk2hhxosgGV33TY9VAm1PAWB9bs2jgbCMcKhJ9fy5xgadkVJoPsLl+p5kvHilwnBzjB7aGAjVZVKjTA== Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id w18-20020a05620a149200b00785620d3199si974688qkj.433.2024.02.07.04.45.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 04:45:59 -0800 (PST) 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=@embecosm.com header.s=google header.b=PnK+QKD+; arc=pass (i=1); 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 7B0F838582B8 for ; Wed, 7 Feb 2024 12:45:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id 2D9E63858408 for ; Wed, 7 Feb 2024 12:44:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2D9E63858408 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2D9E63858408 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::336 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707309844; cv=none; b=bcFibKaHswTsGIB/9tOQopa7zwIjx1WLuU+3qi8G0yHWI0vz3u2p2RkV+Rapp/RbYT6pmtxCcgMhEZNU3iD0sOzaul+JyFnUHUj8y5OMlseUwlne+D5dg3nB8JqP5iNAVu38fqTDJ2XU688e/H63T180nyLFRyb3cmhgEy98Lgk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707309844; c=relaxed/simple; bh=OYaHbYEg1Xa7OWC+Elpa6YqFmUg5IG9jOXaRSUIDdC0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=lryukG97viVVN7iMwedNKdLvSx3+4w6aQ5SVjQOTr7Aso0Zcpny/IXRsMSdKLQ/goVml/NAzu8iC4MBN5NmBwMq0ze3EhHeo6tWzC+dbxqP0jKdbrnfuqZShKyazDwlXJRnepIFXxZRgGIG1aQgEkkrt5F+F2BAYVUCY9ykIcrU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-40fe3141e1cso5519375e9.0 for ; Wed, 07 Feb 2024 04:44:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1707309840; x=1707914640; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=/fNGjZZmxhwFlkSqq00nmBtJDdnKifsuatlSnq1lGh4=; b=PnK+QKD+wLSFDhiNVLnUOT7petn1fV1ucdAEdS4CG4IXgMgGWAnjTfLh36dMPygIpn aDhUa/SOcsUQK4X9iJjlpI9CuwS0GtvOdj5pBV3GPViWPBV6un8WfrKTxJ2tS/CI5FlY 5Sg10SEXuTeNY+oQtcLttksrpH28Uma3+b376ucWvNQhbXJIgezLjzEKlMaOvTvn8afk Itq9AH0hlQmx5C3s9YGx91UkKejAv5a7p+f9M8p90yVcxrAAZlU+vBtdmBGM6uZW2LIK 9xdXONHpZ75w7ouf/Zi5ybRmRvTLTxc5mKzzc5ULkxSg66KJoRYm1wayee103LI0s+lG H3Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707309840; x=1707914640; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/fNGjZZmxhwFlkSqq00nmBtJDdnKifsuatlSnq1lGh4=; b=J2Yycln9bxWxO5wrwAtBrLcy1cXpLKOHgL+pz9CIsKxkDzSOpuBM53GFv1WRaK5zri ibt5sL02Fch6o6vcsoPzZwABo5hwo7oxx5XMs3qE19x2QlEz745pFGdRAPZHrnF+w+DS AAcnz8e7p8xMPxo8nraxFwoe6Ge7igQGHhDRdxpiOAX/hbOTlzZnDx//Crk2PVr1xMr1 vVUY6QMJbUbWgkAHbPByBDefDWUoT0pp3BcePyZAjDsHqZylt2k//lW8OZzm+JZKdAWv J7+ZK9hXdFxJugMndZD/nfQB2v6LzqaYEAwxrnOrNx/+5irYTLbl2AyaAWbmlJQwYEW0 eZHQ== X-Gm-Message-State: AOJu0YycQf/hHQG7j8bdlmA2HGcB/UxM6t0EVs9d1L+nK3VluFmlhycz qU4kHP8s8oeIhcAkflzihymiIwRqj8UUdNFFi9JEXIY5SwZ+1hraccs+IpmsZB3UWNG3+Ac1FhZ JDg== X-Received: by 2002:a05:600c:35c3:b0:40e:f589:50bf with SMTP id r3-20020a05600c35c300b0040ef58950bfmr4103428wmq.15.1707309839990; Wed, 07 Feb 2024 04:43:59 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVMMfN11E1OM2TeNOCJj5ic8cyC2a0jxzptRfsbr9FBuSPbXGMD8Kzp6M87ReeqwAs1s0pJ2kHk4Jn8EM4SdMHdRMWyjEDu Received: from platypus.sou.embecosm-corp.com ([212.69.42.53]) by smtp.gmail.com with ESMTPSA id x19-20020a05600c2a5300b0040fbdd6f69bsm5044188wme.33.2024.02.07.04.43.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 04:43:59 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Kushal Pal Subject: [COMMITTED 01/25] gccrs: Parse normal functions with `self` parameter correctly Date: Wed, 7 Feb 2024 12:43:47 +0100 Message-ID: <20240207114419.1100894-2-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.42.1 MIME-Version: 1.0 X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: arthur.cohen@embecosm.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790244248760034260 X-GMAIL-MSGID: 1790244248760034260 From: Kushal Pal Fixes #2812 gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_function): Skip token if its a COMMA. gcc/testsuite/ChangeLog: * rust/compile/issue-2812.rs: New test. Signed-off-by: Kushal Pal --- gcc/rust/parse/rust-parse-impl.h | 4 ++-- gcc/testsuite/rust/compile/issue-2812.rs | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/rust/compile/issue-2812.rs diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index c622ed7bc97..89e3731a898 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -2946,8 +2946,8 @@ Parser::parse_function (AST::Visibility vis, && initial_param.error () != ParseSelfError::NOT_SELF) return nullptr; - if (initial_param.has_value ()) - skip_token (COMMA); + if (initial_param.has_value () && lexer.peek_token ()->get_id () == COMMA) + skip_token (); // parse function parameters (only if next token isn't right paren) std::vector> function_params; diff --git a/gcc/testsuite/rust/compile/issue-2812.rs b/gcc/testsuite/rust/compile/issue-2812.rs new file mode 100644 index 00000000000..173259b1291 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-2812.rs @@ -0,0 +1,4 @@ +// { dg-additional-options "-frust-compile-until=astvalidation" } +fn foo_1(&self); +fn foo_1(&mut self); +fn foo_1(self);