]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Fix ICE in check for unused global variables
authorPhilip Herron <herron.philip@googlemail.com>
Fri, 5 May 2023 16:16:08 +0000 (17:16 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:37:15 +0000 (18:37 +0100)
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 <herron.philip@googlemail.com>
gcc/rust/checks/lints/rust-lint-unused-var.cc

index f60cfacd1f0bd7f318d26500a49ddd49f6b53e22..4928fb27aa8cb7d77dab9f265692c8170d2633f2 100644 (file)
@@ -17,7 +17,7 @@
 // <http://www.gnu.org/licenses/>.
 
 #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 ())