about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorFolkert <folkert@folkertdev.nl>2024-08-04 16:43:12 +0200
committerFolkert de Vries <folkert@folkertdev.nl>2024-10-06 18:12:25 +0200
commit0aec55504cf188d99b2047e49aad9027604df89e (patch)
treec75a51ef823ba5eb348804219e6f0f7168e7f0c3 /tests
parentaa5bbf05f424ae7bfb2bd859141c7e8553120d87 (diff)
use `naked_asm!` in `tests/ui/asm/naked-functions.rs`
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/asm/naked-functions.rs72
-rw-r--r--tests/ui/asm/naked-functions.stderr184
2 files changed, 117 insertions, 139 deletions
diff --git a/tests/ui/asm/naked-functions.rs b/tests/ui/asm/naked-functions.rs
index 116a84506c5..86c89ea1262 100644
--- a/tests/ui/asm/naked-functions.rs
+++ b/tests/ui/asm/naked-functions.rs
@@ -6,7 +6,7 @@
 #![feature(asm_unwind, linkage)]
 #![crate_type = "lib"]
 
-use std::arch::asm;
+use std::arch::naked_asm;
 
 #[repr(C)]
 pub struct P {
@@ -25,7 +25,7 @@ pub unsafe extern "C" fn patterns(
     P { x, y }: P,
     //~^ ERROR patterns not allowed in naked function parameters
 ) {
-    asm!("", options(noreturn))
+    naked_asm!("", options(noreturn))
 }
 
 #[naked]
@@ -38,9 +38,8 @@ pub unsafe extern "C" fn inc(a: u32) -> u32 {
 #[naked]
 #[allow(asm_sub_register)]
 pub unsafe extern "C" fn inc_asm(a: u32) -> u32 {
-    asm!("/* {0} */", in(reg) a, options(noreturn));
-    //~^ ERROR referencing function parameters is not allowed in naked functions
-    //~| ERROR only `const` and `sym` operands are supported in naked functions
+    naked_asm!("/* {0} */", in(reg) a, options(noreturn))
+    //~^ ERROR the `in` operand cannot be used with `naked_asm!`
 }
 
 #[naked]
@@ -59,10 +58,9 @@ pub unsafe extern "C" fn unsupported_operands() {
     let mut e = 0usize;
     const F: usize = 0usize;
     static G: usize = 0usize;
-    asm!("/* {0} {1} {2} {3} {4} {5} {6} */",
-         //~^ ERROR asm in naked functions must use `noreturn` option
+    naked_asm!("/* {0} {1} {2} {3} {4} {5} {6} */",
          in(reg) a,
-         //~^ ERROR only `const` and `sym` operands are supported in naked functions
+         //~^ ERROR the `in` operand cannot be used with `naked_asm!`
          inlateout(reg) b,
          inout(reg) c,
          lateout(reg) d,
@@ -81,13 +79,13 @@ pub extern "C" fn missing_assembly() {
 pub extern "C" fn too_many_asm_blocks() {
     //~^ ERROR naked functions must contain a single asm block
     unsafe {
-        asm!("");
+        naked_asm!("");
         //~^ ERROR asm in naked functions must use `noreturn` option
-        asm!("");
+        naked_asm!("");
         //~^ ERROR asm in naked functions must use `noreturn` option
-        asm!("");
+        naked_asm!("");
         //~^ ERROR asm in naked functions must use `noreturn` option
-        asm!("", options(noreturn));
+        naked_asm!("", options(noreturn));
     }
 }
 
@@ -103,40 +101,42 @@ pub fn outer(x: u32) -> extern "C" fn(usize) -> usize {
 
 #[naked]
 unsafe extern "C" fn invalid_options() {
-    asm!("", options(nomem, preserves_flags, noreturn));
-    //~^ ERROR asm options unsupported in naked functions: `nomem`, `preserves_flags`
+    naked_asm!("", options(nomem, preserves_flags, noreturn));
+    //~^ ERROR the `nomem` option cannot be used with `naked_asm!`
+    //~| ERROR the `preserves_flags` option cannot be used with `naked_asm!`
 }
 
 #[naked]
 unsafe extern "C" fn invalid_options_continued() {
-    asm!("", options(readonly, nostack), options(pure));
-    //~^ ERROR asm with the `pure` option must have at least one output
-    //~| ERROR asm options unsupported in naked functions: `pure`, `readonly`, `nostack`
+    naked_asm!("", options(readonly, nostack), options(pure));
+    //~^ ERROR the `readonly` option cannot be used with `naked_asm!`
+    //~| ERROR the `nostack` option cannot be used with `naked_asm!`
+    //~| ERROR the `pure` option cannot be used with `naked_asm!`
     //~| ERROR asm in naked functions must use `noreturn` option
 }
 
 #[naked]
 unsafe extern "C" fn invalid_may_unwind() {
-    asm!("", options(noreturn, may_unwind));
-    //~^ ERROR asm options unsupported in naked functions: `may_unwind`
+    naked_asm!("", options(noreturn, may_unwind));
+    //~^ ERROR the `may_unwind` option cannot be used with `naked_asm!`
 }
 
 #[naked]
 pub unsafe fn default_abi() {
     //~^ WARN Rust ABI is unsupported in naked functions
-    asm!("", options(noreturn));
+    naked_asm!("", options(noreturn));
 }
 
 #[naked]
 pub unsafe fn rust_abi() {
     //~^ WARN Rust ABI is unsupported in naked functions
-    asm!("", options(noreturn));
+    naked_asm!("", options(noreturn));
 }
 
 #[naked]
 pub extern "C" fn valid_a<T>() -> T {
     unsafe {
-        asm!("", options(noreturn));
+        naked_asm!("", options(noreturn));
     }
 }
 
@@ -145,7 +145,7 @@ pub extern "C" fn valid_b() {
     unsafe {
         {
             {
-                asm!("", options(noreturn));
+                naked_asm!("", options(noreturn));
             };
         };
     }
@@ -153,13 +153,13 @@ pub extern "C" fn valid_b() {
 
 #[naked]
 pub unsafe extern "C" fn valid_c() {
-    asm!("", options(noreturn));
+    naked_asm!("", options(noreturn));
 }
 
 #[cfg(target_arch = "x86_64")]
 #[naked]
 pub unsafe extern "C" fn valid_att_syntax() {
-    asm!("", options(noreturn, att_syntax));
+    naked_asm!("", options(noreturn, att_syntax));
 }
 
 #[naked]
@@ -173,12 +173,12 @@ pub unsafe extern "C" fn allow_compile_error(a: u32) -> u32 {
 pub unsafe extern "C" fn allow_compile_error_and_asm(a: u32) -> u32 {
     compile_error!("this is a user specified error");
     //~^ ERROR this is a user specified error
-    asm!("", options(noreturn))
+    naked_asm!("", options(noreturn))
 }
 
 #[naked]
 pub unsafe extern "C" fn invalid_asm_syntax(a: u32) -> u32 {
-    asm!(invalid_syntax)
+    naked_asm!(invalid_syntax)
     //~^ ERROR asm template must be a string literal
 }
 
@@ -186,7 +186,7 @@ pub unsafe extern "C" fn invalid_asm_syntax(a: u32) -> u32 {
 #[cfg_attr(target_pointer_width = "64", no_mangle)]
 #[naked]
 pub unsafe extern "C" fn compatible_cfg_attributes() {
-    asm!("", options(noreturn, att_syntax));
+    naked_asm!("", options(noreturn, att_syntax));
 }
 
 #[allow(dead_code)]
@@ -195,20 +195,20 @@ pub unsafe extern "C" fn compatible_cfg_attributes() {
 #[forbid(dead_code)]
 #[naked]
 pub unsafe extern "C" fn compatible_diagnostic_attributes() {
-    asm!("", options(noreturn, raw));
+    naked_asm!("", options(noreturn, raw));
 }
 
 #[deprecated = "test"]
 #[naked]
 pub unsafe extern "C" fn compatible_deprecated_attributes() {
-    asm!("", options(noreturn, raw));
+    naked_asm!("", options(noreturn, raw));
 }
 
 #[cfg(target_arch = "x86_64")]
 #[must_use]
 #[naked]
 pub unsafe extern "C" fn compatible_must_use_attributes() -> u64 {
-    asm!(
+    naked_asm!(
         "
         mov rax, 42
         ret
@@ -222,20 +222,20 @@ pub unsafe extern "C" fn compatible_must_use_attributes() -> u64 {
 #[no_mangle]
 #[naked]
 pub unsafe extern "C" fn compatible_ffi_attributes_1() {
-    asm!("", options(noreturn, raw));
+    naked_asm!("", options(noreturn, raw));
 }
 
 #[cold]
 #[naked]
 pub unsafe extern "C" fn compatible_codegen_attributes() {
-    asm!("", options(noreturn, raw));
+    naked_asm!("", options(noreturn, raw));
 }
 
 #[cfg(target_arch = "x86_64")]
 #[target_feature(enable = "sse2")]
 #[naked]
 pub unsafe extern "C" fn compatible_target_feature() {
-    asm!("", options(noreturn));
+    naked_asm!("", options(noreturn));
 }
 
 #[doc = "foo bar baz"]
@@ -244,11 +244,11 @@ pub unsafe extern "C" fn compatible_target_feature() {
 #[doc(alias = "ADocAlias")]
 #[naked]
 pub unsafe extern "C" fn compatible_doc_attributes() {
-    asm!("", options(noreturn, raw));
+    naked_asm!("", options(noreturn, raw));
 }
 
 #[linkage = "external"]
 #[naked]
 pub unsafe extern "C" fn compatible_linkage() {
-    asm!("", options(noreturn, raw));
+    naked_asm!("", options(noreturn, raw));
 }
diff --git a/tests/ui/asm/naked-functions.stderr b/tests/ui/asm/naked-functions.stderr
index 93c02e2fbef..22c1946a960 100644
--- a/tests/ui/asm/naked-functions.stderr
+++ b/tests/ui/asm/naked-functions.stderr
@@ -1,8 +1,50 @@
-error: asm with the `pure` option must have at least one output
-  --> $DIR/naked-functions.rs:112:14
+error: the `in` operand cannot be used with `naked_asm!`
+  --> $DIR/naked-functions.rs:41:29
    |
-LL |     asm!("", options(readonly, nostack), options(pure));
-   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^
+LL |     naked_asm!("/* {0} */", in(reg) a, options(noreturn))
+   |                             ^^ the `in` operand is not meaningful for global-scoped inline assembly, remove it
+
+error: the `in` operand cannot be used with `naked_asm!`
+  --> $DIR/naked-functions.rs:62:10
+   |
+LL |          in(reg) a,
+   |          ^^ the `in` operand is not meaningful for global-scoped inline assembly, remove it
+
+error: the `nomem` option cannot be used with `naked_asm!`
+  --> $DIR/naked-functions.rs:104:28
+   |
+LL |     naked_asm!("", options(nomem, preserves_flags, noreturn));
+   |                            ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly
+
+error: the `preserves_flags` option cannot be used with `naked_asm!`
+  --> $DIR/naked-functions.rs:104:35
+   |
+LL |     naked_asm!("", options(nomem, preserves_flags, noreturn));
+   |                                   ^^^^^^^^^^^^^^^ the `preserves_flags` option is not meaningful for global-scoped inline assembly
+
+error: the `readonly` option cannot be used with `naked_asm!`
+  --> $DIR/naked-functions.rs:111:28
+   |
+LL |     naked_asm!("", options(readonly, nostack), options(pure));
+   |                            ^^^^^^^^ the `readonly` option is not meaningful for global-scoped inline assembly
+
+error: the `nostack` option cannot be used with `naked_asm!`
+  --> $DIR/naked-functions.rs:111:38
+   |
+LL |     naked_asm!("", options(readonly, nostack), options(pure));
+   |                                      ^^^^^^^ the `nostack` option is not meaningful for global-scoped inline assembly
+
+error: the `pure` option cannot be used with `naked_asm!`
+  --> $DIR/naked-functions.rs:111:56
+   |
+LL |     naked_asm!("", options(readonly, nostack), options(pure));
+   |                                                        ^^^^ the `pure` option is not meaningful for global-scoped inline assembly
+
+error: the `may_unwind` option cannot be used with `naked_asm!`
+  --> $DIR/naked-functions.rs:120:38
+   |
+LL |     naked_asm!("", options(noreturn, may_unwind));
+   |                                      ^^^^^^^^^^ the `may_unwind` option is not meaningful for global-scoped inline assembly
 
 error: this is a user specified error
   --> $DIR/naked-functions.rs:168:5
@@ -17,10 +59,10 @@ LL |     compile_error!("this is a user specified error");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: asm template must be a string literal
-  --> $DIR/naked-functions.rs:181:10
+  --> $DIR/naked-functions.rs:181:16
    |
-LL |     asm!(invalid_syntax)
-   |          ^^^^^^^^^^^^^^
+LL |     naked_asm!(invalid_syntax)
+   |                ^^^^^^^^^^^^^^
 
 error: patterns not allowed in naked function parameters
   --> $DIR/naked-functions.rs:19:5
@@ -63,22 +105,8 @@ LL |
 LL |     a + 1
    |     ----- non-asm is unsupported in naked functions
 
-error: referencing function parameters is not allowed in naked functions
-  --> $DIR/naked-functions.rs:41:31
-   |
-LL |     asm!("/* {0} */", in(reg) a, options(noreturn));
-   |                               ^
-   |
-   = help: follow the calling convention in asm block to use parameters
-
-error[E0787]: only `const` and `sym` operands are supported in naked functions
-  --> $DIR/naked-functions.rs:41:23
-   |
-LL |     asm!("/* {0} */", in(reg) a, options(noreturn));
-   |                       ^^^^^^^^^
-
 error[E0787]: naked functions must contain a single asm block
-  --> $DIR/naked-functions.rs:47:1
+  --> $DIR/naked-functions.rs:46:1
    |
 LL | pub unsafe extern "C" fn inc_closure(a: u32) -> u32 {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -86,40 +114,8 @@ LL |
 LL |     (|| a + 1)()
    |     ------------ non-asm is unsupported in naked functions
 
-error[E0787]: only `const` and `sym` operands are supported in naked functions
-  --> $DIR/naked-functions.rs:64:10
-   |
-LL |          in(reg) a,
-   |          ^^^^^^^^^
-LL |
-LL |          inlateout(reg) b,
-   |          ^^^^^^^^^^^^^^^^
-LL |          inout(reg) c,
-   |          ^^^^^^^^^^^^
-LL |          lateout(reg) d,
-   |          ^^^^^^^^^^^^^^
-LL |          out(reg) e,
-   |          ^^^^^^^^^^
-
-error[E0787]: asm in naked functions must use `noreturn` option
-  --> $DIR/naked-functions.rs:62:5
-   |
-LL | /     asm!("/* {0} {1} {2} {3} {4} {5} {6} */",
-LL | |
-LL | |          in(reg) a,
-LL | |
-...  |
-LL | |          sym G,
-LL | |     );
-   | |_____^
-   |
-help: consider specifying that the asm block is responsible for returning from the function
-   |
-LL |          sym G, options(noreturn),
-   |               +++++++++++++++++++
-
 error[E0787]: naked functions must contain a single asm block
-  --> $DIR/naked-functions.rs:53:1
+  --> $DIR/naked-functions.rs:52:1
    |
 LL | pub unsafe extern "C" fn unsupported_operands() {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -136,61 +132,61 @@ LL |     let mut e = 0usize;
    |     ------------------- non-asm is unsupported in naked functions
 
 error[E0787]: naked functions must contain a single asm block
-  --> $DIR/naked-functions.rs:76:1
+  --> $DIR/naked-functions.rs:74:1
    |
 LL | pub extern "C" fn missing_assembly() {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0787]: asm in naked functions must use `noreturn` option
-  --> $DIR/naked-functions.rs:84:9
+  --> $DIR/naked-functions.rs:82:9
    |
-LL |         asm!("");
-   |         ^^^^^^^^
+LL |         naked_asm!("");
+   |         ^^^^^^^^^^^^^^
    |
 help: consider specifying that the asm block is responsible for returning from the function
    |
-LL |         asm!("", options(noreturn));
-   |                +++++++++++++++++++
+LL |         naked_asm!("", options(noreturn));
+   |                      +++++++++++++++++++
 
 error[E0787]: asm in naked functions must use `noreturn` option
-  --> $DIR/naked-functions.rs:86:9
+  --> $DIR/naked-functions.rs:84:9
    |
-LL |         asm!("");
-   |         ^^^^^^^^
+LL |         naked_asm!("");
+   |         ^^^^^^^^^^^^^^
    |
 help: consider specifying that the asm block is responsible for returning from the function
    |
-LL |         asm!("", options(noreturn));
-   |                +++++++++++++++++++
+LL |         naked_asm!("", options(noreturn));
+   |                      +++++++++++++++++++
 
 error[E0787]: asm in naked functions must use `noreturn` option
-  --> $DIR/naked-functions.rs:88:9
+  --> $DIR/naked-functions.rs:86:9
    |
-LL |         asm!("");
-   |         ^^^^^^^^
+LL |         naked_asm!("");
+   |         ^^^^^^^^^^^^^^
    |
 help: consider specifying that the asm block is responsible for returning from the function
    |
-LL |         asm!("", options(noreturn));
-   |                +++++++++++++++++++
+LL |         naked_asm!("", options(noreturn));
+   |                      +++++++++++++++++++
 
 error[E0787]: naked functions must contain a single asm block
-  --> $DIR/naked-functions.rs:81:1
+  --> $DIR/naked-functions.rs:79:1
    |
 LL | pub extern "C" fn too_many_asm_blocks() {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 ...
-LL |         asm!("");
-   |         -------- multiple asm blocks are unsupported in naked functions
+LL |         naked_asm!("");
+   |         -------------- multiple asm blocks are unsupported in naked functions
 LL |
-LL |         asm!("");
-   |         -------- multiple asm blocks are unsupported in naked functions
+LL |         naked_asm!("");
+   |         -------------- multiple asm blocks are unsupported in naked functions
 LL |
-LL |         asm!("", options(noreturn));
-   |         --------------------------- multiple asm blocks are unsupported in naked functions
+LL |         naked_asm!("", options(noreturn));
+   |         --------------------------------- multiple asm blocks are unsupported in naked functions
 
 error: referencing function parameters is not allowed in naked functions
-  --> $DIR/naked-functions.rs:98:11
+  --> $DIR/naked-functions.rs:96:11
    |
 LL |         *&y
    |           ^
@@ -198,7 +194,7 @@ LL |         *&y
    = help: follow the calling convention in asm block to use parameters
 
 error[E0787]: naked functions must contain a single asm block
-  --> $DIR/naked-functions.rs:96:5
+  --> $DIR/naked-functions.rs:94:5
    |
 LL |     pub extern "C" fn inner(y: usize) -> usize {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -206,34 +202,16 @@ LL |
 LL |         *&y
    |         --- non-asm is unsupported in naked functions
 
-error[E0787]: asm options unsupported in naked functions: `nomem`, `preserves_flags`
-  --> $DIR/naked-functions.rs:106:5
-   |
-LL |     asm!("", options(nomem, preserves_flags, noreturn));
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error[E0787]: asm options unsupported in naked functions: `pure`, `readonly`, `nostack`
-  --> $DIR/naked-functions.rs:112:5
-   |
-LL |     asm!("", options(readonly, nostack), options(pure));
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
 error[E0787]: asm in naked functions must use `noreturn` option
-  --> $DIR/naked-functions.rs:112:5
+  --> $DIR/naked-functions.rs:111:5
    |
-LL |     asm!("", options(readonly, nostack), options(pure));
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |     naked_asm!("", options(readonly, nostack), options(pure));
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
 help: consider specifying that the asm block is responsible for returning from the function
    |
-LL |     asm!("", options(noreturn), options(readonly, nostack), options(pure));
-   |            +++++++++++++++++++
-
-error[E0787]: asm options unsupported in naked functions: `may_unwind`
-  --> $DIR/naked-functions.rs:120:5
-   |
-LL |     asm!("", options(noreturn, may_unwind));
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |     naked_asm!("", options(noreturn), options(readonly, nostack), options(pure));
+   |                  +++++++++++++++++++
 
 warning: Rust ABI is unsupported in naked functions
   --> $DIR/naked-functions.rs:125:1