aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
diff options
context:
space:
mode:
authorNobel <nobel2073@gmail.com>2024-12-21 23:56:39 +0545
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-21 12:56:56 +0100
commit1cad5f2bed18f673112e3b256c64c836fde2550a (patch)
tree4d25475cf38610caf15b441fc351f33f9353c08e /gcc/rust
parentf821a513843baabed8a39601bbc714558110b748 (diff)
downloadgcc-1cad5f2bed18f673112e3b256c64c836fde2550a.zip
gcc-1cad5f2bed18f673112e3b256c64c836fde2550a.tar.gz
gcc-1cad5f2bed18f673112e3b256c64c836fde2550a.tar.bz2
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 <nobel2073@gmail.com>
Diffstat (limited to 'gcc/rust')
-rw-r--r--gcc/rust/typecheck/rust-casts.cc6
1 files changed, 6 insertions, 0 deletions
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 ()};