From patchwork Tue Jan 31 13:24:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 50857 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2748744wrn; Tue, 31 Jan 2023 05:26:27 -0800 (PST) X-Google-Smtp-Source: AK7set/ltKKy1YANxbGnmG62SA+qw1QLBpHlCt2RK/KB92JLFQkOjJ083zV8cwXnixBIXSO74MKc X-Received: by 2002:a50:d692:0:b0:4a2:3d2e:6502 with SMTP id r18-20020a50d692000000b004a23d2e6502mr10651364edi.4.1675171587352; Tue, 31 Jan 2023 05:26:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675171587; cv=none; d=google.com; s=arc-20160816; b=yfHi+ABePTkt8Uzv4wVVHQxNJ+i8BEw2oB8BtkvXk/ggYwXKZMxEko95x8iwDNubCD IUKOKCUsGzmpHFGCciemuHH+2zPFAc2AB8hJKgdCOL+hCLx0HD/0JI344P6pqR9vhcye +6SjlY0eA3ntEtsoYb2qU3C9FwI8+Vnc4srovd8PnUBjc1oSjCjlT4xFXhwn3CIadSTx Yrt1Kp+b0KG3ZX+4Rs2If+BJkoB39iQuyqm8V4YqybLlLV9Y8GS4wNrb/jtdWq0dgit9 Vza0QBskXKTd5XtD+HTifujPHpfTJRHvX+zG8qGIprbGrJwJjMd3EUTKMX9LTN7vz6uF hz6w== 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:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dmarc-filter:delivered-to; bh=Ks7reYZh1+f57aPaPqyaf6A+piUpOMPEb1MjknoNq+M=; b=VsFIZ2hjysT9dE+nk6uifof9dRRSBNE3y1Ywqtuxa0ZMb4ONGrcaHY1ZIs2AqdIQiP 6JIr1T/e7fyhndpWUu1dDSVweNlPbmq3/Lpq9qISeZHwnmnEclQJxnnbxzAFQH+G233p hQg+JVoN0ep+f+pOSWbWkuhgpal4iH/IY8+Hf4dTu+CxmGnZkXTFyRhHZez5BLhIYUHA xDxneuFDW+VaijFoidOtl6ffw0DjZaGV+J0ycYatHETfjdjcIYJuwWkwYanGg1ggiXMX eCAGRwkFenHQmG6mvmcaL9ys4kmgfCdOZscdFwBpHWgoO1LOdHyH8VcBVm55gv5dOnLN 4EtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=YYqdayMB; 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id g12-20020a056402428c00b0049e24a14a25si524756edc.250.2023.01.31.05.26.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 05:26:27 -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=YYqdayMB; 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 244343896C2A for ; Tue, 31 Jan 2023 13:22:39 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 602CF3854153 for ; Tue, 31 Jan 2023 13:21:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 602CF3854153 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-x436.google.com with SMTP id q5so14224120wrv.0 for ; Tue, 31 Jan 2023 05:21:04 -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=Ks7reYZh1+f57aPaPqyaf6A+piUpOMPEb1MjknoNq+M=; b=YYqdayMB6oGdeHxntS/przqCejEOy3yONTCHFsSeMxSBaXnuffJYSFttgUV6QCQ/tR 9h5cDkjvc3+96UOQpJinTYZlLH8+DQZ/JT2SKyv9xsBdiiRBQy4tyUWKkJXwxeX2dwtu DWBAhVmg60gFqzH61bd0fwSjsowQjpaw9J6QkWmszGagpUB4dToykO/I2tTJ7T1B9eMD zEZQBcVUMThw182PrJ2KPx8xr7fHysU/tQHDYbBlnHHzkpkOvvYSBh1YXvxk25+CI4bE l+y6h0CucIVmLJTfNMbFEl+6B7KTvc7ky2Mb4b/H5cbxAD6p8PNxr1fj36lmzWbqW1or naPQ== 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=Ks7reYZh1+f57aPaPqyaf6A+piUpOMPEb1MjknoNq+M=; b=YDpooMbLgdLHEeuQd4r1H3fXOZQbC2FOoL474OP3GAlnSTd5QFRTdQ6x5MKL4aEkY/ F7KevwEEgYNw32sc070adGvxLTQw2hWYhiFAZMQSwK9eMhkElQ6EuwTMpwtmrHXZdpNo tNDV9BEmfEMD1n88Juh5ubQulx4IRaZi/Gj3sPkTZDfMXDMsSuEKi9rfiJ7ZcLB3bEJH RFmzdTtYRHnbBGLPGjzzHIFJRYxeLDuUfQ4pbKH+mwRyIdOF0v2DnCNeXgv3RsvYD1ze WCv6Ob4fo+cDYvTOle6dvg9YBB3m/ce5u9dDzi5Z+c9UTZdyiyySNOVFarRpwTeBBuAp xPsw== X-Gm-Message-State: AO0yUKVT4dVW7nP8D8us8cuUf9xrCFvGno+CGLVFKIWsigWai5yiuZCR NcfvtAO5NMVife/nO75NCpNwFgo1LL3YaCRX4Q== X-Received: by 2002:a5d:6804:0:b0:2bf:ad43:8f08 with SMTP id w4-20020a5d6804000000b002bfad438f08mr24817412wru.14.1675171262887; Tue, 31 Jan 2023 05:21:02 -0800 (PST) Received: from platypus.lan ([2001:861:5e4c:3bb0:6424:328a:1734:3249]) by smtp.gmail.com with ESMTPSA id x7-20020a5d6b47000000b002bbed1388a5sm14871543wrw.15.2023.01.31.05.21.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 05:21:02 -0800 (PST) From: Arthur Cohen To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Arthur Cohen , philberty Subject: [COMMITTED] gccrs: transcriber: Do not infinite loop if the current parsed node is an error Date: Tue, 31 Jan 2023 14:24:48 +0100 Message-Id: <20230131132448.661684-1-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Spam-Status: No, score=-15.8 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=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.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?1756544722104209695?= X-GMAIL-MSGID: =?utf-8?q?1756544722104209695?= gcc/rust/ChangeLog: * expand/rust-macro-expand.cc (parse_many): Return early from parsing loop if we encounter an error, and emit that error in the meantime. Co-authored-by: philberty Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/rust/expand/rust-macro-expand.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gcc/rust/expand/rust-macro-expand.cc b/gcc/rust/expand/rust-macro-expand.cc index df258bd96ec..ed1b838c987 100644 --- a/gcc/rust/expand/rust-macro-expand.cc +++ b/gcc/rust/expand/rust-macro-expand.cc @@ -731,6 +731,14 @@ parse_many (Parser &parser, TokenId &delimiter, break; auto node = parse_fn (); + if (node.is_error ()) + { + for (auto err : parser.get_errors ()) + err.emit_error (); + + return AST::ASTFragment::create_error (); + } + nodes.emplace_back (std::move (node)); }