diff options
author | Philip Herron <herron.philip@googlemail.com> | 2025-03-27 12:04:41 +0000 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-31 21:07:16 +0200 |
commit | 4c2b0c1d885fd01d20f252155df1578278548367 (patch) | |
tree | 7b958be04479189e8768719b0360a30774242c09 /gcc/testsuite | |
parent | 0b522745670e83ee4b5af0782982743b3f715c30 (diff) | |
download | gcc-4c2b0c1d885fd01d20f252155df1578278548367.zip gcc-4c2b0c1d885fd01d20f252155df1578278548367.tar.gz gcc-4c2b0c1d885fd01d20f252155df1578278548367.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/testsuite')
-rw-r--r-- | gcc/testsuite/rust/compile/issue-3566-1.rs | 8 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/issue-3566-2.rs | 22 |
2 files changed, 30 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/issue-3566-1.rs b/gcc/testsuite/rust/compile/issue-3566-1.rs new file mode 100644 index 0000000..b7e5be0 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3566-1.rs @@ -0,0 +1,8 @@ +mod a { + pub mod b { + + pub fn f(x: [u8; { 100 }]) -> [u8; { 100 }] { + x + } + } +} diff --git a/gcc/testsuite/rust/compile/issue-3566-2.rs b/gcc/testsuite/rust/compile/issue-3566-2.rs new file mode 100644 index 0000000..3f3ea73 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3566-2.rs @@ -0,0 +1,22 @@ +// run-pass + +#![allow(H8)] +#![allow(dead_code)] + + +// pretty-expanded FIXME #23616 + +mod a { + pub mod b { + pub type t = isize; + + pub fn f(x: [u8; { let s = 17; 100 }]) -> [u8; { let z = 18; 100 }] { + //~^ WARN unused variable: `s` + //~| WARN unused variable: `z` + x +} + } +} + +pub fn main() { //~ ERROR cannot move out + } |