aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-expr.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/backend/rust-compile-expr.cc')
-rw-r--r--gcc/rust/backend/rust-compile-expr.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc
index 6d50c3f..03e3c2e 100644
--- a/gcc/rust/backend/rust-compile-expr.cc
+++ b/gcc/rust/backend/rust-compile-expr.cc
@@ -1339,18 +1339,22 @@ CompileExpr::visit (HIR::IdentifierExpr &expr)
Bvariable *var = nullptr;
if (ctx->lookup_const_decl (ref, &translated))
{
+ TREE_USED (translated) = 1;
return;
}
else if (ctx->lookup_function_decl (ref, &fn))
{
+ TREE_USED (fn) = 1;
translated = address_expression (fn, expr.get_locus ());
}
else if (ctx->lookup_var_decl (ref, &var))
{
+ // TREE_USED is setup in the gcc abstraction here
translated = ctx->get_backend ()->var_expression (var, expr.get_locus ());
}
else if (ctx->lookup_pattern_binding (ref, &translated))
{
+ TREE_USED (translated) = 1;
return;
}
else
@@ -1371,6 +1375,11 @@ CompileExpr::visit (HIR::IdentifierExpr &expr)
else
translated = CompileItem::compile (resolved_item, ctx, lookup, true,
expr.get_locus ());
+
+ if (translated != error_mark_node)
+ {
+ TREE_USED (translated) = 1;
+ }
}
}