aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-item.cc
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-09-22 12:20:49 +0000
committerGitHub <noreply@github.com>2022-09-22 12:20:49 +0000
commit6da3cab7b0acf5dc363c85069bef716923ddf90c (patch)
tree4f78124e43846c0dfb272858ed60cc681236a140 /gcc/rust/backend/rust-compile-item.cc
parentf252b4093666cf1e3d948b22f00fc12bf283a83f (diff)
parent5f01d6c53734802955568771e75df68ffc2fd0d8 (diff)
downloadgcc-6da3cab7b0acf5dc363c85069bef716923ddf90c.zip
gcc-6da3cab7b0acf5dc363c85069bef716923ddf90c.tar.gz
gcc-6da3cab7b0acf5dc363c85069bef716923ddf90c.tar.bz2
Merge #1541
1541: Static const eval safety r=philberty a=philberty This adds a test case for the rust issue: https://blog.rust-lang.org/2022/09/15/const-eval-safety-rule-revision.html Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-item.cc')
-rw-r--r--gcc/rust/backend/rust-compile-item.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/rust/backend/rust-compile-item.cc b/gcc/rust/backend/rust-compile-item.cc
index 96c4e7f..8ba17c9 100644
--- a/gcc/rust/backend/rust-compile-item.cc
+++ b/gcc/rust/backend/rust-compile-item.cc
@@ -43,13 +43,18 @@ CompileItem::visit (HIR::StaticItem &var)
rust_assert (ok);
tree type = TyTyResolveCompile::compile (ctx, resolved_type);
- tree value = CompileExpr::Compile (var.get_expr (), ctx);
const Resolver::CanonicalPath *canonical_path = nullptr;
ok = ctx->get_mappings ()->lookup_canonical_path (
var.get_mappings ().get_nodeid (), &canonical_path);
rust_assert (ok);
+ HIR::Expr *const_value_expr = var.get_expr ();
+ ctx->push_const_context ();
+ tree value = compile_constant_item (ctx, resolved_type, canonical_path,
+ const_value_expr, var.get_locus ());
+ ctx->pop_const_context ();
+
std::string name = canonical_path->get ();
std::string asm_name = ctx->mangle_item (resolved_type, *canonical_path);