From patchwork Wed Apr 5 14:04:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 79742 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp372769vqo; Wed, 5 Apr 2023 08:02:32 -0700 (PDT) X-Google-Smtp-Source: AKy350Zzbfm1g5GKC9o/UatEXYRyOipMyesHuetUDgegeiPtUOBEJ7cOnJiObKk+6wjnwtQyqJQP X-Received: by 2002:a17:907:2bf5:b0:93b:b8f3:225d with SMTP id gv53-20020a1709072bf500b0093bb8f3225dmr3255571ejc.15.1680706952579; Wed, 05 Apr 2023 08:02:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680706952; cv=none; d=google.com; s=arc-20160816; b=CWxsFU8DM4fOmdovA4C2MY9mV6jlNH623wQjR/Ma4fdK4X9gdKHaFAkUKbwnU/ca53 AA9l6mIDmxnEADAnb/qR5ZGT3pzYBOo1mgl/zZfg1mXsDA3QWoetX56rjsVqzXvUiZH/ MXoHKOO8e9QLfkbOQ1vaDuMgZKU7U9KucKnHloYqRJZYkczWfuHSLuj0EFMN1Y+XgS35 qMtE4Az3+lvS9LNfTa0AsTHTo5NGfDXbTyJ7np/hHsEfB5LgnTO3PYyOtnrD0dwqSJ+X umfDNxR09kjZJ0Wg4Btai/nn0FZwKzIuzkyoHgFGEyaII0fmcS5OlpxD0SClsj0TXIF/ /alw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dmarc-filter :delivered-to; bh=us33c9zBlXTuTIl37971m5lshOelpNhwhp2riFXNhko=; b=lpc5TSI5AbbDGxq+du9sC3HEtwRUDRbLR0yqdmC09L0c3h6+eyr2RcCXhVRBAb7SPa Om4ucY7OOQ5IVWBweTLu5FguHz4P7OD/Hghh3AJVJajaOzIJWbgKIR8228dS3xWbTtzB Ysph80+7lRj8NQWXiG3QQcis3n/WCTV7CD1D6vJmLtxxt0q8rlDdlLvkWKR+upDV7om3 ehSOZ5cv35Zgb0/sLs9t74/p9vx/MATNNvR3Z5XFcNzooXbLYb5KA5RLy5MZvgwt7t24 MNBd/Q2BPir3MFFSA9ch4+bTRRA44SsDUZeoY+inovYkVAsnGqGsflKwJAiGBGeB2BJX xeoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=escybUj+; 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 m26-20020a1709066d1a00b009309c7f5650si4446078ejr.23.2023.04.05.08.02.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 08:02:32 -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=@embecosm.com header.s=google header.b=escybUj+; 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 94C3539A2545 for ; Wed, 5 Apr 2023 14:23:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id 162403857023 for ; Wed, 5 Apr 2023 14:06:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 162403857023 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wm1-x331.google.com with SMTP id l10-20020a05600c1d0a00b003f04bd3691eso7161801wms.5 for ; Wed, 05 Apr 2023 07:06:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1680703589; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=us33c9zBlXTuTIl37971m5lshOelpNhwhp2riFXNhko=; b=escybUj+EKOMD7Y2XLwqWOCg60fpep69jUdJCMF03KHH5Bmx3d61u3tuwxNv3ocBOQ mmeB67jCxuuJTRKqLkhaYDl6gjyV/TYTy/w+mHUbRZ+mi8NANuH2DV5Xy0Xn7orzd7Y8 pmtRHwP72xFPp8DDN9LpQpItHN0YExJHZu8dBDcl+RCZ3BjFazt9cQAG8xPI2X+P7Ovb WyIfuWgbOUe4g8oAOv2r2ilTvdTjqWasbLqjGIFKozfv3L6XoskV5cvw7cIOv12zwb7p s6oz/ukl3M6qPhDd9T4G6b1ykcN1JOLhqeSURuRY/iVig+cKhLXE8yWtdHqsNk7RqxYu 5RuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680703589; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=us33c9zBlXTuTIl37971m5lshOelpNhwhp2riFXNhko=; b=CPraLl3Z28VPeNHVBNihaMcYT1qj/CBQBtMiRNKGikzmDBRr2oZ5e/ytIkrAWVYJeV kvQLEte3GLWkJbOmHAVmJflwV2Z6UzGfviKG/Kj1TEmErOSf2XoSrJJRGLRXXUlUcb+a VdEprsmOxvqQVlshAEurzO/7S9eg31Om1tI8ZZoEQ8hQ/BXRaWS+eV4u/g9ooEBSnVpG gGy8qBkQlFcQtkCbRKhSoftQU51MbeA9EWiyfmlhDWoSLxajEHRMJyXdncQBY/nF/ZwX fDgQtKU3HO4CbTHrIQAgYtO/NzvCj78yZOmukUro/8mjdM6I1B402lVXo/y7PYdArFU8 C6Mg== X-Gm-Message-State: AAQBX9cUhhVfJdz1jpF+2FX3y5TDShVabtubute84tpM69GKNWrQ5RAH WDGQ8/Fjvv6+Xv+/7hHpJatlzD+UUh1l3kuKmA== X-Received: by 2002:a05:600c:25a:b0:3ed:237f:3da with SMTP id 26-20020a05600c025a00b003ed237f03damr5208026wmj.22.1680703589461; Wed, 05 Apr 2023 07:06:29 -0700 (PDT) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id ay8-20020a05600c1e0800b003edddae1068sm2330150wmb.9.2023.04.05.07.06.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 07:06:29 -0700 (PDT) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Owen Avery Subject: [committed 88/88] gccrs: Fix issue with parsing unsafe block expression statements Date: Wed, 5 Apr 2023 16:04:12 +0200 Message-Id: <20230405140411.3016563-89-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230405140411.3016563-1-arthur.cohen@embecosm.com> References: <20230405140411.3016563-1-arthur.cohen@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.5 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 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: , Reply-To: arthur.cohen@embecosm.com 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?1762348973556714863?= X-GMAIL-MSGID: =?utf-8?q?1762348973556714863?= From: Owen Avery gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_stmt): Handle unsafe expression statements. gcc/testsuite/ChangeLog: * rust/compile/issue-1422.rs: New test. Signed-off-by: Owen Avery --- gcc/rust/parse/rust-parse-impl.h | 10 +++++++++- gcc/testsuite/rust/compile/issue-1422.rs | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/rust/compile/issue-1422.rs diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 1e5b2dc85ed..db32803ddbe 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -6131,7 +6131,15 @@ Parser::parse_stmt (ParseRestrictions restrictions) /* if any of these (should be all possible VisItem prefixes), parse a * VisItem can't parse item because would require reparsing outer * attributes */ - return parse_vis_item (std::move (outer_attrs)); + // may also be unsafe block + if (lexer.peek_token (1)->get_id () == LEFT_CURLY) + { + return parse_expr_stmt (std::move (outer_attrs), restrictions); + } + else + { + return parse_vis_item (std::move (outer_attrs)); + } break; case SUPER: case SELF: diff --git a/gcc/testsuite/rust/compile/issue-1422.rs b/gcc/testsuite/rust/compile/issue-1422.rs new file mode 100644 index 00000000000..b178cda185e --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-1422.rs @@ -0,0 +1,7 @@ +macro_rules! test { + () => { unsafe {} }; +} + +fn main() { + test!(); +}