From: Pierre-Emmanuel Patry <pierre-emmanuel.pa...@embecosm.com>

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 <pierre-emmanuel.pa...@embecosm.com>
---
 .../rust/execute/inline_asm_inout_ident.rs    | 23 ++++++++++++++++++
 .../rust/execute/inline_asm_inout_var.rs      | 24 +++++++++++++++++++
 2 files changed, 47 insertions(+)
 create mode 100644 gcc/testsuite/rust/execute/inline_asm_inout_ident.rs
 create mode 100644 gcc/testsuite/rust/execute/inline_asm_inout_var.rs

diff --git a/gcc/testsuite/rust/execute/inline_asm_inout_ident.rs 
b/gcc/testsuite/rust/execute/inline_asm_inout_ident.rs
new file mode 100644
index 00000000000..b0a3d25a2a7
--- /dev/null
+++ b/gcc/testsuite/rust/execute/inline_asm_inout_ident.rs
@@ -0,0 +1,23 @@
+/* { dg-output "Value is: 5\r*\n" } */
+#![feature(rustc_attrs)]
+
+extern "C" {
+    fn printf(s: *const i8, ...);
+}
+
+#[rustc_builtin_macro]
+macro_rules! asm {
+    () => {};
+}
+
+fn main() -> i32 {
+    let x: i32;
+    // `inout` can also move values to different places
+    unsafe {
+        asm!("inc {}", inout(reg) 4u64=>x);
+    }
+    unsafe {
+        printf("Value is: %i\n\0" as *const str as *const i8, x);
+    }
+    0
+}
diff --git a/gcc/testsuite/rust/execute/inline_asm_inout_var.rs 
b/gcc/testsuite/rust/execute/inline_asm_inout_var.rs
new file mode 100644
index 00000000000..ff101b86b7b
--- /dev/null
+++ b/gcc/testsuite/rust/execute/inline_asm_inout_var.rs
@@ -0,0 +1,24 @@
+/* { dg-output "Value is: 5\r*\n" } */
+#![feature(rustc_attrs)]
+
+extern "C" {
+    fn printf(s: *const i8, ...);
+}
+
+#[rustc_builtin_macro]
+macro_rules! asm {
+    () => {};
+}
+
+fn main() -> i32 {
+    let y: i32 = 4;
+    let x: i32;
+    // `inout` can also move values to different places
+    unsafe {
+        asm!("inc {}", inout(reg) y=>x);
+    }
+    unsafe {
+        printf("Value is: %i\n\0" as *const str as *const i8, x);
+    }
+    0
+}
-- 
2.49.0

Reply via email to