[committed,048/103] gccrs: Add closures to lints and error checking

Message ID 20230221120230.596966-49-arthur.cohen@embecosm.com
State Unresolved
Headers
Series [committed,001/103] gccrs: Fix missing dead code analysis ICE on local enum definition |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Arthur Cohen Feb. 21, 2023, 12:01 p.m. UTC
  From: Philip Herron <philip.herron@embecosm.com>

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(-)
  

Patch

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<HirId> worklist;
   std::set<HirId> liveSymbols;