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: 63984 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7E345395A44D for ; Tue, 31 Jan 2023 13:22:29 +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-Google-Smtp-Source: AK7set/EWVBLgwhgyWVEKcOc7p+TvD9YA+6raDxV3Fy55fVE7ZKNpkuXVQphIz+myI3ejyIkmpMvJQ== 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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)); }