From 1cad5f2bed18f673112e3b256c64c836fde2550a Mon Sep 17 00:00:00 2001 From: Nobel Date: Sat, 21 Dec 2024 23:56:39 +0545 Subject: gccrs: Allow float type to be casted as integer type gccrs now should be able to cast float types as numeric. gcc/rust/ChangeLog: * typecheck/rust-casts.cc (TypeCastRules::cast_rules): Add rule. gcc/testsuite/ChangeLog: * rust/compile/cast_float_as_integer.rs: New test. Signed-off-by: Nobel Singh --- gcc/rust/typecheck/rust-casts.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/rust') diff --git a/gcc/rust/typecheck/rust-casts.cc b/gcc/rust/typecheck/rust-casts.cc index 694cbaa..90bdef1 100644 --- a/gcc/rust/typecheck/rust-casts.cc +++ b/gcc/rust/typecheck/rust-casts.cc @@ -235,6 +235,12 @@ TypeCastRules::cast_rules () case TyTy::TypeKind::FLOAT: switch (to.get_ty ()->get_kind ()) { + case TyTy::TypeKind::USIZE: + case TyTy::TypeKind::ISIZE: + case TyTy::TypeKind::UINT: + case TyTy::TypeKind::INT: + return TypeCoercionRules::CoercionResult{{}, to.get_ty ()->clone ()}; + case TyTy::TypeKind::FLOAT: return TypeCoercionRules::CoercionResult{{}, to.get_ty ()->clone ()}; -- cgit v1.1