diff --git a/c2rust-transpile/src/translator/operators.rs b/c2rust-transpile/src/translator/operators.rs index da006d07c6..fedff6db62 100644 --- a/c2rust-transpile/src/translator/operators.rs +++ b/c2rust-transpile/src/translator/operators.rs @@ -797,7 +797,7 @@ impl<'c> Translation<'c> { }; Ok(WithStmts::new( - vec![save_old_val, mk().expr_stmt(assign_stmt)], + vec![save_old_val, mk().semi_stmt(assign_stmt)], mk().ident_expr(val_name), )) }, diff --git a/tests/ints/src/test_volatile.rs b/tests/ints/src/test_volatile.rs index 3045d70f03..3cde5d75bf 100644 --- a/tests/ints/src/test_volatile.rs +++ b/tests/ints/src/test_volatile.rs @@ -1,13 +1,22 @@ -use crate::volatile::rust_entry3; +use crate::volatile::{rust_entry3, rust_volatile_stuff}; use libc::{c_int, c_uint}; #[link(name = "test")] extern "C" { + fn volatile_stuff(); + fn entry3(_: c_uint, _: *mut c_int); } const BUFFER_SIZE: usize = 9; +pub fn test_compiles() { + unsafe { + volatile_stuff(); + rust_volatile_stuff(); + } +} + pub fn test_buffer() { let mut buffer = [0; BUFFER_SIZE]; let mut rust_buffer = [0; BUFFER_SIZE]; diff --git a/tests/ints/src/volatile.c b/tests/ints/src/volatile.c index 2dd78c47d0..82173934ba 100644 --- a/tests/ints/src/volatile.c +++ b/tests/ints/src/volatile.c @@ -44,4 +44,9 @@ void entry3(const unsigned buffer_size, int buffer[]) buffer[8] = s.buffer[3]; } - +void volatile_stuff(void) +{ + volatile int x1 = 0; + int x2 = x1++; + x2; +}