]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: add checks for division by zero and left shift overflow
authorPhilip Herron <herron.philip@googlemail.com>
Mon, 2 Dec 2024 13:54:29 +0000 (13:54 +0000)
committerArthur Cohen <arthur.cohen@embecosm.com>
Fri, 21 Mar 2025 11:33:08 +0000 (12:33 +0100)
commit5ac2f2864ca65d691ab461f1a176e80028aaee76
tree646c1bf055111fb950e62fcf0e9dbced3ce25dbf
parent9a53a1d1abe2e97207a7bf9ed4db735c4bafb771
gccrs: add checks for division by zero and left shift overflow

These are ported from the c-family code c-warn.cc and c/c-typchk.cc

Fixes Rust-GCC#2394

gcc/rust/ChangeLog:

* backend/rust-constexpr.cc (eval_store_expression): check for null
(eval_call_expression): remove bad warning
* rust-gcc.cc (arithmetic_or_logical_expression): add warnings

gcc/testsuite/ChangeLog:

* rust/compile/issue-2394.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/backend/rust-constexpr.cc
gcc/rust/rust-gcc.cc
gcc/testsuite/rust/compile/issue-2394.rs [new file with mode: 0644]