-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ptr->int and int->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 <[email protected]>
- Loading branch information
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |