diff options
author | Nobel <nobel2073@gmail.com> | 2024-12-23 04:04:44 +0545 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-21 12:55:43 +0100 |
commit | 3396da354e52f17b8dfd2bf13b06e30b2ac2176b (patch) | |
tree | 32749417b2d12680e9bae2c842d8516d5ab58026 /gcc/testsuite/rust | |
parent | 6b27b7807545d985abde8a332c9f37e0d8657fb8 (diff) | |
download | gcc-3396da354e52f17b8dfd2bf13b06e30b2ac2176b.zip gcc-3396da354e52f17b8dfd2bf13b06e30b2ac2176b.tar.gz gcc-3396da354e52f17b8dfd2bf13b06e30b2ac2176b.tar.bz2 |
gccrs: add ptr to int and int to ptr type cast rules
Added rules to allow type casting pointer as integer types (u*,i*)
and integer types to be casted as pointer.
gcc/rust/ChangeLog:
* typecheck/rust-casts.cc (TypeCastRules::cast_rules): Add rule.
gcc/testsuite/ChangeLog:
* rust/compile/ptr_int_cast.rs: New test.
Signed-off-by: Nobel Singh <nobel2073@gmail.com>
Diffstat (limited to 'gcc/testsuite/rust')
-rw-r--r-- | gcc/testsuite/rust/compile/ptr_int_cast.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/ptr_int_cast.rs b/gcc/testsuite/rust/compile/ptr_int_cast.rs new file mode 100644 index 0000000..3a2a5d5 --- /dev/null +++ b/gcc/testsuite/rust/compile/ptr_int_cast.rs @@ -0,0 +1,18 @@ +fn main(){ + let foo = 1337; + let bar_ptr = &foo as *const i32; + + let bar_ptr_usize = bar_ptr as usize; + let bar_ptr_isize = bar_ptr as isize; + let bar_ptr_u64 = bar_ptr as u64; + let bar_ptr_i64 = bar_ptr as i64; + let bar_ptr_i8 = bar_ptr as i8; + let bar_ptr_u8 = bar_ptr as u8; + + let _ = bar_ptr_usize as *const i32; + let _ = bar_ptr_isize as *const i32; + let _ = bar_ptr_u64 as *const i32; + let _ = bar_ptr_i64 as *const i32; + let _ = bar_ptr_i8 as *const i32; + let _ = bar_ptr_u8 as *const i32; +} |