diff options
author | Philip Herron <philip.herron@embecosm.com> | 2022-09-17 10:04:49 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2022-09-17 10:04:49 +0100 |
commit | 53f4a8601c1db2068390dce7012c16b383864740 (patch) | |
tree | b4f044f15ae1e0bd12876ab8106a0823b89456b3 /gcc | |
parent | f252b4093666cf1e3d948b22f00fc12bf283a83f (diff) | |
download | gcc-53f4a8601c1db2068390dce7012c16b383864740.zip gcc-53f4a8601c1db2068390dce7012c16b383864740.tar.gz gcc-53f4a8601c1db2068390dce7012c16b383864740.tar.bz2 |
Static Items must be const evaluated
Statics like constants need to have a singular value they are not functions
to be lazy evaluated. So to evaluate a block expr we can just reuse our
const code to resolve this to a singular value.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/backend/rust-compile-item.cc | 7 |
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); |