From patchwork Tue Feb 21 12:01:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 59991 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1832202wrn; Tue, 21 Feb 2023 04:26:10 -0800 (PST) X-Google-Smtp-Source: AK7set+c5DBCajUDqdzo4sFmdgjGJO7/lCb6bu+2Z2+yi8XSzgqW246oWgVYRYZ0jBQcP0UDuYnS X-Received: by 2002:a17:906:2b16:b0:8b1:5903:6a01 with SMTP id a22-20020a1709062b1600b008b159036a01mr17756835ejg.77.1676982369916; Tue, 21 Feb 2023 04:26:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676982369; cv=none; d=google.com; s=arc-20160816; b=n50Z9FItN0J2S5E21UHOSOZzYxWS8CWYRuFeN37LejzAoepbif9459Zk9sVLD60Y8i tAUQQuiZY8XLS4Ih4YVmYER8P4Exs7XAEvBt0+GQavF/uDXfdljqvipR9skm3CqN2dFu 25apGp5M62Ay4ltRgCdVT1Ix8Zk0PPLvlzLjoZzS0AyFJfFWcO9rOqBe/Vn06RFcXxn2 O++A94W+FKlhEJ5hmz0pNfkF4oss8do2z4K7Xf60iiCzHjvLTkbEdNu1e85VnnYLGPHZ GKZlkXINSVEB/cqqySR6hgwKsaHX1cScOGCcbl6S1RbnOQYyFkuf5oW+c07W/8fsRM58 I7Ag== 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=i9xkM9ea5e6EmRQaVJzdKZ3ladU8rRb31u8pdwTtQPk=; b=zO1Ar2cG/WEzVssZ3l74vfyHTBqOUp28hlhftHE43cU8hS0EiBxDQgSgX0H2GYIq3y ebEzbuu6eaMkssTHeTYHfAS0L3p4LAeC/0fnNVBmNS7jiZ76mB0BiEm7WzS+tsJPYbNm avRdK/t0aZokWtkgEydwcdk5K36WWdsxwNwAAxIe6kOp+RidHc97/Ek2NdYeBfi/NQWU dI3ycf/Zb3CHTMHCH1gjtofyjPcArWRrYOZ+vy9mmFH3uI4QXHmLrb2YURqNIrVgqGDj OB0YoBt4fxLE2W4fVF1M9zw+T3JoOvqHigldYyZAv+YvBGUSVxhmvO27bZ8dcXg3CSYR SlBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=Et42iL+N; 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 ad24-20020a170907259800b008dc1a5182desi3425935ejc.979.2023.02.21.04.26.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 04:26:09 -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=Et42iL+N; 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 880EA3890975 for ; Tue, 21 Feb 2023 12:10:24 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id 8887E383814A for ; Tue, 21 Feb 2023 12:04:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8887E383814A 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-x42a.google.com with SMTP id c12so4163432wrw.1 for ; Tue, 21 Feb 2023 04:04:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; 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=i9xkM9ea5e6EmRQaVJzdKZ3ladU8rRb31u8pdwTtQPk=; b=Et42iL+NzAFCKDtzqoNF56x2YmgAzXeDJqYwGZ2sym5jUdXxZDWRKl+Fw4yZg6zJdL ZM1SYqr0gRU+Rg9yRMUtE7Ytp62IU5dLF+9LfyoDmXcUT/vmy4T63NLWp0pKog9K9/4U wWZc17bNWyIa/mI9T2pedE6nHlVrB4B1GAjZXMtaLkDUt4GcP+51aBm8EVsesaDKvPm1 9CWURKiwsMIPqLZK2nnkVipQZqGwjQZ0my4DaCr1/+As5vYYD7NlA4VM3EhdkkWUES/g k2jYOgV/fUC+W5hVA645Ncu6/I51Ls8lP1VvxcWj/Qk6A/SF5ob3FgabruGQBWIc7deB ZmpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=i9xkM9ea5e6EmRQaVJzdKZ3ladU8rRb31u8pdwTtQPk=; b=MUPQneQHnqeyN2pAxa/WOAhy66BTJdStzcvCrdpYp9xLz21IuTvpGw5dN4iTB69EWR aeHvmaHEN1Pp61jZhXJfuNN0sxQmSAImurBpXj95+TXH+hQUNvIVkyNRr0RIDzrkgyev 0hgUexKn1U2KB00jUbwurYe8lVh9HLtxZQ49bCa0DozrdbGbj/GQI4IQMqM9n/VTFDvb bRLtHxj4FhZogpjknrCEitVF1ypM7OutAZ0ozdaKr5qMKWnsvR7XEJ9FaXSrhyVTOqPC s5B7TL1MRT6nZAMtUh19PjF7dsl+q8mZaE9nK9tK1WUJv4r0rg8BlvBKy9LDGoQKchur YEfA== X-Gm-Message-State: AO0yUKWZEuiXG8N857oLRJ9iMa1Jd01MoyQ7hh2Xn1Fv/EhyciRH4Pw2 0AnZqqvmIVHFT4zmsKc5fB1mlen83AyxyjslvA== X-Received: by 2002:a5d:5486:0:b0:2be:c41:4758 with SMTP id h6-20020a5d5486000000b002be0c414758mr2396543wrv.38.1676981042894; Tue, 21 Feb 2023 04:04:02 -0800 (PST) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id c15-20020adffb4f000000b002c55b0e6ef1sm5013811wrs.4.2023.02.21.04.04.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 04:04:02 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Philip Herron Subject: [committed 048/103] gccrs: Add closures to lints and error checking Date: Tue, 21 Feb 2023 13:01:38 +0100 Message-Id: <20230221120230.596966-49-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230221120230.596966-1-arthur.cohen@embecosm.com> References: <20230221120230.596966-1-arthur.cohen@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.4 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: , 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?1758443465831930586?= X-GMAIL-MSGID: =?utf-8?q?1758443465831930586?= From: Philip Herron gcc/rust/ChangeLog: * checks/errors/rust-const-checker.cc (ConstChecker::visit): Visit closures properly. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise. * checks/lints/rust-lint-marklive.h: Likewise. --- gcc/rust/checks/errors/rust-const-checker.cc | 4 +++- gcc/rust/checks/errors/rust-unsafe-checker.cc | 4 +++- gcc/rust/checks/lints/rust-lint-marklive.h | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gcc/rust/checks/errors/rust-const-checker.cc b/gcc/rust/checks/errors/rust-const-checker.cc index 01dc2620767..9161fa1ea2a 100644 --- a/gcc/rust/checks/errors/rust-const-checker.cc +++ b/gcc/rust/checks/errors/rust-const-checker.cc @@ -383,7 +383,9 @@ ConstChecker::visit (FieldAccessExpr &expr) void ConstChecker::visit (ClosureExpr &expr) -{} +{ + expr.get_expr ()->accept_vis (*this); +} void ConstChecker::visit (BlockExpr &expr) diff --git a/gcc/rust/checks/errors/rust-unsafe-checker.cc b/gcc/rust/checks/errors/rust-unsafe-checker.cc index 02868794cbc..3d534743eeb 100644 --- a/gcc/rust/checks/errors/rust-unsafe-checker.cc +++ b/gcc/rust/checks/errors/rust-unsafe-checker.cc @@ -454,7 +454,9 @@ UnsafeChecker::visit (FieldAccessExpr &expr) void UnsafeChecker::visit (ClosureExpr &expr) -{} +{ + expr.get_expr ()->accept_vis (*this); +} void UnsafeChecker::visit (BlockExpr &expr) diff --git a/gcc/rust/checks/lints/rust-lint-marklive.h b/gcc/rust/checks/lints/rust-lint-marklive.h index 4caf18ce186..dcc625d0b9d 100644 --- a/gcc/rust/checks/lints/rust-lint-marklive.h +++ b/gcc/rust/checks/lints/rust-lint-marklive.h @@ -285,6 +285,11 @@ public: item->accept_vis (*this); } + void visit (HIR::ClosureExpr &expr) override + { + expr.get_expr ()->accept_vis (*this); + } + private: std::vector worklist; std::set liveSymbols;