Skip to content

Commit 46d72b9

Browse files
P-E-PCohenArthur
authored andcommitted
Add execute test for variable and identifiers
gcc/testsuite/ChangeLog: * rust/execute/inline_asm_inout_ident.rs: New test. * rust/execute/inline_asm_inout_var.rs: New test. Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
1 parent d4676fb commit 46d72b9

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* { dg-output "Value is: 5\r*\n" } */
2+
#![feature(rustc_attrs)]
3+
4+
extern "C" {
5+
fn printf(s: *const i8, ...);
6+
}
7+
8+
#[rustc_builtin_macro]
9+
macro_rules! asm {
10+
() => {};
11+
}
12+
13+
fn main() -> i32 {
14+
let x: i32;
15+
// `inout` can also move values to different places
16+
unsafe {
17+
asm!("inc {}", inout(reg) 4u64=>x);
18+
}
19+
unsafe {
20+
printf("Value is: %i\n\0" as *const str as *const i8, x);
21+
}
22+
0
23+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* { dg-output "Value is: 5\r*\n" } */
2+
#![feature(rustc_attrs)]
3+
4+
extern "C" {
5+
fn printf(s: *const i8, ...);
6+
}
7+
8+
#[rustc_builtin_macro]
9+
macro_rules! asm {
10+
() => {};
11+
}
12+
13+
fn main() -> i32 {
14+
let y: i32 = 4;
15+
let x: i32;
16+
// `inout` can also move values to different places
17+
unsafe {
18+
asm!("inc {}", inout(reg) y=>x);
19+
}
20+
unsafe {
21+
printf("Value is: %i\n\0" as *const str as *const i8, x);
22+
}
23+
0
24+
}

0 commit comments

Comments
 (0)