Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow float type to be casted as integer type #3319

Merged
merged 1 commit into from
Jan 10, 2025

Conversation

nobel-sh
Copy link
Contributor

#3270 added rules for int -> float casts but not the opposite .
This PR should add support for float -> int casts and fully fix #3261.

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 <[email protected]>
Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but waiting for Philip :)

Copy link
Member

@philberty philberty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@philberty philberty added this to the Remaining typecheck issues milestone Jan 10, 2025
@philberty philberty added this pull request to the merge queue Jan 10, 2025
Merged via the queue into Rust-GCC:master with commit c960e03 Jan 10, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Restricted type casting from integer types to float types and vice versa
3 participants