diff options
author | Philip Herron <herron.philip@googlemail.com> | 2025-03-27 12:04:41 +0000 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2025-03-27 13:22:30 +0000 |
commit | 6c14a3b702b4fc693705a64674285900b2ec8b47 (patch) | |
tree | 2fe3b0f309d7e30d2be3d7dae2f503a035a5e35a /gcc/rust/backend/rust-compile-base.h | |
parent | 31ee9259a71742a455ead61c8b6142dcfab28b0f (diff) | |
download | gcc-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.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-base.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-base.h b/gcc/rust/backend/rust-compile-base.h index 3c50535..4d55407 100644 --- a/gcc/rust/backend/rust-compile-base.h +++ b/gcc/rust/backend/rust-compile-base.h @@ -31,6 +31,12 @@ public: static tree address_expression (tree expr, location_t locus); + static tree 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); + protected: HIRCompileBase (Context *ctx) : ctx (ctx) {} |