aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/rust-gcc.cc
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2025-04-16 17:13:04 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2025-04-28 16:18:53 +0200
commit2cbb3bf90dd75f26f865eb4d9d51eaeca30f33a7 (patch)
treec59d91dfa3acc17a54c6ad39c6be624e5849e963 /gcc/rust/rust-gcc.cc
parent75a57211f698242d247f5c4230b8348b236f9ded (diff)
downloadgcc-2cbb3bf90dd75f26f865eb4d9d51eaeca30f33a7.zip
gcc-2cbb3bf90dd75f26f865eb4d9d51eaeca30f33a7.tar.gz
gcc-2cbb3bf90dd75f26f865eb4d9d51eaeca30f33a7.tar.bz2
gccrs: Fix ICE when checking shift's which are behind array refs
I copied a bad form of this check from the c front-end this updates it to ensure the rhs is an INTEGER_CST and the lhs needs checked in the first place. Fixes Rust-GCC#3664 gcc/rust/ChangeLog: * rust-gcc.cc (arithmetic_or_logical_expression): Ensure this is an integer gcc/testsuite/ChangeLog: * rust/compile/issue-3664.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust/rust-gcc.cc')
-rw-r--r--gcc/rust/rust-gcc.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index 234721c..e5319d3 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -1109,6 +1109,7 @@ arithmetic_or_logical_expression (ArithmeticOrLogicalOperator op, tree left,
rust_error_at (location, "division by zero");
}
else if (op == ArithmeticOrLogicalOperator::LEFT_SHIFT
+ && TREE_CODE (right) == INTEGER_CST
&& (compare_tree_int (right, TYPE_PRECISION (TREE_TYPE (ret))) >= 0))
{
rust_error_at (location, "left shift count >= width of type");