From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id 53ADE385B53C for ; Tue, 31 Jan 2023 13:20:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 53ADE385B53C 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-wr1-x433.google.com with SMTP id h12so14168129wrv.10 for ; Tue, 31 Jan 2023 05:20:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=yx1EkOB5oQAliWFePh1g/87UCXXNpsdiAMhrMKdyFEU=; b=Iu0BUzjFZME7mooZoAV2on6Jcth62nf1os0VE0pRGyqxUA4ywkGgzF2561Qb9FqEVY azefuGpCel+kEx/fzKdzHTd+eeugNIkvXCDgDMgVwQFJaohg6WbUv5ni7zjnrz+jKzU2 05X8gaOmTakSWngam56HSOBujBOAIim4qgJ7D7408SPiNMExkx7xD4eaElZdlaPkwV1G /W4hCnwhnWDBsPDuL/YgglzZ/nX+8iwC6WodRHYa8ubF+ccXIw0u8++TMc2UT3hcaR// 4BAO8+pnb2eqf/drwKkjP1Jx8tifDY+EOgz0+SfRmwuiCk8r8UuDDsUOGDqNIO/5rtnZ fLVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=yx1EkOB5oQAliWFePh1g/87UCXXNpsdiAMhrMKdyFEU=; b=RbSznKD+B3eoUIMBSvUJz2z8n82nHqyZ/PrxIDK3GNNgU2k0A3Kl0rjBSk+LQtRE+z yd+lbnl2LfJWOiaNTOqer9nWu4+vCW3aRs3zjgEHCK50xrKCHkJRd2zdUrlTHEeU4l1a cucdr21QyC575aGqlLlr5Qib/LhKWsnV+hHFT57eAabf55EFHNuiLwq2ckmFkozwEBB/ KE6kercfMeEejTd0KbO1D7P0WKAEbIILJ8r5dxqwXOvg7jLedC11ag1gqP5SGtucNU5B Sk+Q90N9hPGPJzNz04bGsPnqwPtcNnnWc+llTMPhAQ/emLf0tq3MSPn2YaRmwy/zLQH7 p3ZQ== X-Gm-Message-State: AO0yUKW0Loz0KLypSMoCFV/sSKJ/aPqQtZlj5w4w6Cz2rFYxgvBr4WMb 0nHQChnh3UgIig5dKcQnpVZAPBpjP7E2fWnzyg== X-Google-Smtp-Source: AK7set+b5qAo14RrAF6WY/ciABK6r0gAbNktx0M6jbabWNhn4ju231vQZD6tHYLxg1Rtto/HjnnEIQ== X-Received: by 2002:a05:6000:1105:b0:2bf:b77c:df78 with SMTP id z5-20020a056000110500b002bfb77cdf78mr22313246wrw.20.1675171250863; Tue, 31 Jan 2023 05:20:50 -0800 (PST) Received: from platypus.lan ([2001:861:5e4c:3bb0:6424:328a:1734:3249]) by smtp.gmail.com with ESMTPSA id j5-20020adff005000000b002bddd75a83fsm14504299wro.8.2023.01.31.05.20.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 05:20:50 -0800 (PST) From: Arthur Cohen To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Arthur Cohen Subject: [COMMITTED] gccrs: parser: Parse RangeFullExpr without erroring out Date: Tue, 31 Jan 2023 14:24:35 +0100 Message-Id: <20230131132435.661532-1-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-15.9 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 List-Id: gcc/rust/ChangeLog: * parse/rust-parse-impl.h: Allow parsing full range expressions without erroring out. gcc/testsuite/ChangeLog: * rust/compile/parse_range.rs: New test. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/rust/parse/rust-parse-impl.h | 6 +++++- gcc/testsuite/rust/compile/parse_range.rs | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/rust/compile/parse_range.rs diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index fe628647653..72207a1bc22 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -14112,9 +14112,13 @@ std::unique_ptr Parser::parse_nud_range_exclusive_expr ( const_TokenPtr tok, AST::AttrVec outer_attrs ATTRIBUTE_UNUSED) { + auto restrictions = ParseRestrictions (); + restrictions.expr_can_be_null = true; + // FIXME: this probably parses expressions accidently or whatever // try parsing RHS (as tok has already been consumed in parse_expression) - std::unique_ptr right = parse_expr (LBP_DOT_DOT, AST::AttrVec ()); + std::unique_ptr right + = parse_expr (LBP_DOT_DOT, AST::AttrVec (), restrictions); Location locus = tok->get_locus (); diff --git a/gcc/testsuite/rust/compile/parse_range.rs b/gcc/testsuite/rust/compile/parse_range.rs new file mode 100644 index 00000000000..03469b1f8d5 --- /dev/null +++ b/gcc/testsuite/rust/compile/parse_range.rs @@ -0,0 +1,9 @@ +// { dg-additional-options "-fsyntax-only" } + +fn main() { + let a = [1, 2, 3, 4]; + let _ = a[0..]; + let _ = a[..3]; + let _ = a[0..3]; + let _ = a[..]; +} -- 2.39.1