From: Philip Herron <[email protected]>

Fixes Rust-GCC/gccrs#4858

gcc/rust/ChangeLog:

        * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): add 
missing checks

gcc/testsuite/ChangeLog:

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

Signed-off-by: Philip Herron <[email protected]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.


Commit on github: 
https://github.com/Rust-GCC/gccrs/commit/7a839f9477ac9e4e3e6659ae0ffe6ef587b87dbb

The commit has been mentioned in the following issue(s):
 - Rust-GCC/gccrs#4858: https://github.com/Rust-GCC/gccrs/issues/4858

The commit has been mentioned in the following pull-request(s):
 - https://github.com/Rust-GCC/gccrs/pull/4871

 gcc/rust/typecheck/rust-hir-type-check-expr.cc |  2 ++
 gcc/testsuite/rust/compile/issue-4858.rs       | 10 ++++++++++
 2 files changed, 12 insertions(+)
 create mode 100644 gcc/testsuite/rust/compile/issue-4858.rs

diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.cc 
b/gcc/rust/typecheck/rust-hir-type-check-expr.cc
index 7f8547f53..a1e4fb5d8 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-expr.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-expr.cc
@@ -612,6 +612,8 @@ TypeCheckExpr::visit (HIR::NegationExpr &expr)
          = (negated_expr_ty->get_kind () == TyTy::TypeKind::BOOL)
            || (negated_expr_ty->get_kind () == TyTy::TypeKind::INT)
            || (negated_expr_ty->get_kind () == TyTy::TypeKind::UINT)
+           || (negated_expr_ty->get_kind () == TyTy::TypeKind::ISIZE)
+           || (negated_expr_ty->get_kind () == TyTy::TypeKind::USIZE)
            || (negated_expr_ty->get_kind () == TyTy::TypeKind::INFER
                && (((TyTy::InferType *) negated_expr_ty)->get_infer_kind ()
                    == TyTy::InferType::INTEGRAL));
diff --git a/gcc/testsuite/rust/compile/issue-4858.rs 
b/gcc/testsuite/rust/compile/issue-4858.rs
new file mode 100644
index 000000000..aab574287
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-4858.rs
@@ -0,0 +1,10 @@
+#![feature(no_core)]
+#![no_core]
+
+pub fn signed(x: isize) -> isize {
+    !x
+}
+
+pub fn unsigned(x: usize) -> usize {
+    !x
+}
-- 
2.55.0

Reply via email to