aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-base.cc
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2025-03-27 12:04:41 +0000
committerPhilip Herron <philip.herron@embecosm.com>2025-03-27 13:22:30 +0000
commit6c14a3b702b4fc693705a64674285900b2ec8b47 (patch)
tree2fe3b0f309d7e30d2be3d7dae2f503a035a5e35a /gcc/rust/backend/rust-compile-base.cc
parent31ee9259a71742a455ead61c8b6142dcfab28b0f (diff)
downloadgcc-6c14a3b702b4fc693705a64674285900b2ec8b47.zip
gcc-6c14a3b702b4fc693705a64674285900b2ec8b47.tar.gz
gcc-6c14a3b702b4fc693705a64674285900b2ec8b47.tar.bz2
gccrs: Fix ICE when compiling block expressions in array capacity
We need to reuse the existing compile_constant_item helper which handles the case if this is a simple expression, fn-call or a block expression. The patch extracts out this helper as a static method so this can be used in more places. Fixes Rust-GCC#3566 gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::address_expression): new helper constexpr * backend/rust-compile-base.h: prototype * backend/rust-compile-type.cc (TyTyResolveCompile::visit): call constexpr helper gcc/testsuite/ChangeLog: * rust/compile/issue-3566-1.rs: New test. * rust/compile/issue-3566-2.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-base.cc')
-rw-r--r--gcc/rust/backend/rust-compile-base.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-base.cc b/gcc/rust/backend/rust-compile-base.cc
index a4d0d06..c71417d 100644
--- a/gcc/rust/backend/rust-compile-base.cc
+++ b/gcc/rust/backend/rust-compile-base.cc
@@ -561,6 +561,18 @@ HIRCompileBase::address_expression (tree expr, location_t location)
}
tree
+HIRCompileBase::compile_constant_expr (
+ Context *ctx, HirId coercion_id, TyTy::BaseType *resolved_type,
+ TyTy::BaseType *expected_type, const Resolver::CanonicalPath &canonical_path,
+ HIR::Expr &const_value_expr, location_t locus, location_t expr_locus)
+{
+ HIRCompileBase c (ctx);
+ return c.compile_constant_item (coercion_id, resolved_type, expected_type,
+ canonical_path, const_value_expr, locus,
+ expr_locus);
+}
+
+tree
HIRCompileBase::indirect_expression (tree expr, location_t locus)
{
if (expr == error_mark_node)