From c6f1b887e8f52ba6252ad83e03cbea41af326f6e Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Fri, 5 May 2023 17:16:08 +0100 Subject: [PATCH] gccrs: Fix ICE in check for unused global variables Calling get variable expression will return an expression but we are checking for unused decls so lets actually pass the decl. Addresses #2188 gcc/rust/ChangeLog: * checks/lints/rust-lint-unused-var.cc (UnusedVariables::Lint): use the decl not the expr Signed-off-by: Philip Herron --- gcc/rust/checks/lints/rust-lint-unused-var.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/rust/checks/lints/rust-lint-unused-var.cc b/gcc/rust/checks/lints/rust-lint-unused-var.cc index f60cfacd1f0b..4928fb27aa8c 100644 --- a/gcc/rust/checks/lints/rust-lint-unused-var.cc +++ b/gcc/rust/checks/lints/rust-lint-unused-var.cc @@ -17,7 +17,7 @@ // . #include "rust-lint-unused-var.h" -#include "print-tree.h" +#include "rust-gcc.h" namespace Rust { namespace Analysis { @@ -84,8 +84,8 @@ UnusedVariables::Lint (Compile::Context &ctx) for (auto &var : ctx.get_var_decls ()) { - tree t = ctx.get_backend ()->var_expression (var, Location ()); - check_decl (&t); + tree decl = var->get_decl (); + check_decl (&decl); } for (auto &const_decl : ctx.get_const_decls ()) -- 2.47.2