Skip to content

Commit 17d24e3

Browse files
committed
transpile: operators: resolve type when checking for unsignedness
other code in operators.rs remembers to do this, but this method forgot fixes #1024
1 parent 0153f8f commit 17d24e3

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

c2rust-transpile/src/translator/operators.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ impl<'c> Translation<'c> {
506506
) -> TranslationResult<Box<Expr>> {
507507
let is_unsigned_integral_type = self
508508
.ast_context
509-
.index(ctype)
509+
.resolve_type(ctype)
510510
.kind
511511
.is_unsigned_integral_type();
512512

c2rust-transpile/tests/snapshots/platform-specific/rnd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub unsafe extern "C" fn set_rand_seed(mut s: uint32_t) {
2424
pub unsafe extern "C" fn get_rand_seed() -> uint32_t {
2525
let INCREMENT: uint32_t = 1 as std::ffi::c_int as uint32_t;
2626
let MULTIPLIER: uint32_t = 0x15a4e35 as std::ffi::c_int as uint32_t;
27-
cur_rand_seed = (MULTIPLIER * cur_rand_seed).wrapping_add(INCREMENT);
27+
cur_rand_seed = MULTIPLIER.wrapping_mul(cur_rand_seed).wrapping_add(INCREMENT);
2828
let mut ret: uint32_t = abs(cur_rand_seed as int32_t) as uint32_t;
2929
return ret;
3030
}

c2rust-transpile/tests/snapshots/[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub unsafe extern "C" fn set_rand_seed(mut s: uint32_t) {
3030
pub unsafe extern "C" fn get_rand_seed() -> uint32_t {
3131
let INCREMENT: uint32_t = 1 as std::ffi::c_int as uint32_t;
3232
let MULTIPLIER: uint32_t = 0x15a4e35 as std::ffi::c_int as uint32_t;
33-
cur_rand_seed = (MULTIPLIER * cur_rand_seed).wrapping_add(INCREMENT);
33+
cur_rand_seed = MULTIPLIER.wrapping_mul(cur_rand_seed).wrapping_add(INCREMENT);
3434
let mut ret: uint32_t = abs(cur_rand_seed as int32_t) as uint32_t;
3535
return ret;
3636
}

c2rust-transpile/tests/snapshots/[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub unsafe extern "C" fn set_rand_seed(mut s: uint32_t) {
2828
pub unsafe extern "C" fn get_rand_seed() -> uint32_t {
2929
let INCREMENT: uint32_t = 1 as std::ffi::c_int as uint32_t;
3030
let MULTIPLIER: uint32_t = 0x15a4e35 as std::ffi::c_int as uint32_t;
31-
cur_rand_seed = (MULTIPLIER * cur_rand_seed).wrapping_add(INCREMENT);
31+
cur_rand_seed = MULTIPLIER.wrapping_mul(cur_rand_seed).wrapping_add(INCREMENT);
3232
let mut ret: uint32_t = abs(cur_rand_seed as int32_t) as uint32_t;
3333
return ret;
3434
}

0 commit comments

Comments
 (0)