From: Philip Herron Date: Fri, 5 May 2023 16:16:08 +0000 (+0100) Subject: gccrs: Fix ICE in check for unused global variables X-Git-Tag: basepoints/gcc-15~2579 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6f1b887e8f52ba6252ad83e03cbea41af326f6e;p=thirdparty%2Fgcc.git 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 --- 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 ())