Remove ui tests for LLVM-style inline assembly

This commit is contained in:
Tomasz Miąsko 2022-01-12 00:00:00 +00:00
parent a76577cb8a
commit 61c233bac3
70 changed files with 74 additions and 1500 deletions

View File

@ -3,12 +3,10 @@
// ignore-spirv
// ignore-wasm32
#![feature(llvm_asm)]
#![feature(naked_functions)]
#![feature(or_patterns)]
#![feature(asm_const, asm_sym)]
#![crate_type = "lib"]
#![allow(deprecated)] // llvm_asm!
use std::arch::asm;
@ -114,16 +112,6 @@ pub fn outer(x: u32) -> extern "C" fn(usize) -> usize {
inner
}
#[naked]
unsafe extern "C" fn llvm() -> ! {
//~^ WARN naked functions must contain a single asm block
//~| WARN this was previously accepted
llvm_asm!("");
//~^ WARN LLVM-style inline assembly is unsupported in naked functions
//~| WARN this was previously accepted
core::hint::unreachable_unchecked();
}
#[naked]
unsafe extern "C" fn invalid_options() {
asm!("", options(nomem, preserves_flags, noreturn));

View File

@ -1,35 +1,35 @@
error: asm with the `pure` option must have at least one output
--> $DIR/naked-functions.rs:136:14
--> $DIR/naked-functions.rs:124:14
|
LL | asm!("", options(readonly, nostack), options(pure));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^
error: patterns not allowed in naked function parameters
--> $DIR/naked-functions.rs:23:5
--> $DIR/naked-functions.rs:21:5
|
LL | mut a: u32,
| ^^^^^
error: patterns not allowed in naked function parameters
--> $DIR/naked-functions.rs:25:5
--> $DIR/naked-functions.rs:23:5
|
LL | &b: &i32,
| ^^
error: patterns not allowed in naked function parameters
--> $DIR/naked-functions.rs:27:6
--> $DIR/naked-functions.rs:25:6
|
LL | (None | Some(_)): Option<std::ptr::NonNull<u8>>,
| ^^^^^^^^^^^^^^
error: patterns not allowed in naked function parameters
--> $DIR/naked-functions.rs:29:5
--> $DIR/naked-functions.rs:27:5
|
LL | P { x, y }: P,
| ^^^^^^^^^^
error: referencing function parameters is not allowed in naked functions
--> $DIR/naked-functions.rs:39:5
--> $DIR/naked-functions.rs:37:5
|
LL | a + 1
| ^
@ -37,7 +37,7 @@ LL | a + 1
= help: follow the calling convention in asm block to use parameters
warning: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:36:1
--> $DIR/naked-functions.rs:34:1
|
LL | / pub unsafe extern "C" fn inc(a: u32) -> u32 {
LL | |
@ -53,7 +53,7 @@ LL | | }
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
error: referencing function parameters is not allowed in naked functions
--> $DIR/naked-functions.rs:45:31
--> $DIR/naked-functions.rs:43:31
|
LL | asm!("/* {0} */", in(reg) a, options(noreturn));
| ^
@ -61,7 +61,7 @@ LL | asm!("/* {0} */", in(reg) a, options(noreturn));
= help: follow the calling convention in asm block to use parameters
warning: only `const` and `sym` operands are supported in naked functions
--> $DIR/naked-functions.rs:45:23
--> $DIR/naked-functions.rs:43:23
|
LL | asm!("/* {0} */", in(reg) a, options(noreturn));
| ^^^^^^^^^
@ -70,7 +70,7 @@ LL | asm!("/* {0} */", in(reg) a, options(noreturn));
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:52:1
--> $DIR/naked-functions.rs:50:1
|
LL | / pub unsafe extern "C" fn inc_closure(a: u32) -> u32 {
LL | |
@ -84,7 +84,7 @@ LL | | }
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: only `const` and `sym` operands are supported in naked functions
--> $DIR/naked-functions.rs:72:10
--> $DIR/naked-functions.rs:70:10
|
LL | in(reg) a,
| ^^^^^^^^^
@ -102,7 +102,7 @@ LL | out(reg) e,
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: asm in naked functions must use `noreturn` option
--> $DIR/naked-functions.rs:69:5
--> $DIR/naked-functions.rs:67:5
|
LL | / asm!("/* {0} {1} {2} {3} {4} {5} {6} */",
LL | |
@ -117,7 +117,7 @@ LL | | );
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:59:1
--> $DIR/naked-functions.rs:57:1
|
LL | / pub unsafe extern "C" fn unsupported_operands() {
LL | |
@ -141,7 +141,7 @@ LL | | }
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:85:1
--> $DIR/naked-functions.rs:83:1
|
LL | / pub extern "C" fn missing_assembly() {
LL | |
@ -153,7 +153,7 @@ LL | | }
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: asm in naked functions must use `noreturn` option
--> $DIR/naked-functions.rs:94:5
--> $DIR/naked-functions.rs:92:5
|
LL | asm!("");
| ^^^^^^^^
@ -162,7 +162,7 @@ LL | asm!("");
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: asm in naked functions must use `noreturn` option
--> $DIR/naked-functions.rs:97:5
--> $DIR/naked-functions.rs:95:5
|
LL | asm!("");
| ^^^^^^^^
@ -171,7 +171,7 @@ LL | asm!("");
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: asm in naked functions must use `noreturn` option
--> $DIR/naked-functions.rs:100:5
--> $DIR/naked-functions.rs:98:5
|
LL | asm!("");
| ^^^^^^^^
@ -180,7 +180,7 @@ LL | asm!("");
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:91:1
--> $DIR/naked-functions.rs:89:1
|
LL | / pub extern "C" fn too_many_asm_blocks() {
LL | |
@ -202,7 +202,7 @@ LL | | }
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
error: referencing function parameters is not allowed in naked functions
--> $DIR/naked-functions.rs:111:11
--> $DIR/naked-functions.rs:109:11
|
LL | *&y
| ^
@ -210,7 +210,7 @@ LL | *&y
= help: follow the calling convention in asm block to use parameters
warning: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:108:5
--> $DIR/naked-functions.rs:106:5
|
LL | / pub extern "C" fn inner(y: usize) -> usize {
LL | |
@ -224,35 +224,8 @@ LL | | }
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: the LLVM-style inline assembly is unsupported in naked functions
--> $DIR/naked-functions.rs:121:5
|
LL | llvm_asm!("");
| ^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
= help: use the new asm! syntax specified in RFC 2873
= note: this warning originates in the macro `llvm_asm` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:118:1
|
LL | / unsafe extern "C" fn llvm() -> ! {
LL | |
LL | |
LL | | llvm_asm!("");
... |
LL | | core::hint::unreachable_unchecked();
| | ------------------------------------ non-asm is unsupported in naked functions
LL | | }
| |_^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: asm options unsupported in naked functions: `nomem`, `preserves_flags`
--> $DIR/naked-functions.rs:129:5
--> $DIR/naked-functions.rs:117:5
|
LL | asm!("", options(nomem, preserves_flags, noreturn));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -261,7 +234,7 @@ LL | asm!("", options(nomem, preserves_flags, noreturn));
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: asm options unsupported in naked functions: `nostack`, `pure`, `readonly`
--> $DIR/naked-functions.rs:136:5
--> $DIR/naked-functions.rs:124:5
|
LL | asm!("", options(readonly, nostack), options(pure));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -270,7 +243,7 @@ LL | asm!("", options(readonly, nostack), options(pure));
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: asm in naked functions must use `noreturn` option
--> $DIR/naked-functions.rs:136:5
--> $DIR/naked-functions.rs:124:5
|
LL | asm!("", options(readonly, nostack), options(pure));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -279,7 +252,7 @@ LL | asm!("", options(readonly, nostack), options(pure));
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: Rust ABI is unsupported in naked functions
--> $DIR/naked-functions.rs:145:15
--> $DIR/naked-functions.rs:133:15
|
LL | pub unsafe fn default_abi() {
| ^^^^^^^^^^^
@ -287,13 +260,13 @@ LL | pub unsafe fn default_abi() {
= note: `#[warn(undefined_naked_function_abi)]` on by default
warning: Rust ABI is unsupported in naked functions
--> $DIR/naked-functions.rs:151:15
--> $DIR/naked-functions.rs:139:15
|
LL | pub unsafe fn rust_abi() {
| ^^^^^^^^
warning: naked functions cannot be inlined
--> $DIR/naked-functions.rs:191:1
--> $DIR/naked-functions.rs:179:1
|
LL | #[inline]
| ^^^^^^^^^
@ -302,7 +275,7 @@ LL | #[inline]
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: naked functions cannot be inlined
--> $DIR/naked-functions.rs:199:1
--> $DIR/naked-functions.rs:187:1
|
LL | #[inline(always)]
| ^^^^^^^^^^^^^^^^^
@ -311,7 +284,7 @@ LL | #[inline(always)]
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: naked functions cannot be inlined
--> $DIR/naked-functions.rs:207:1
--> $DIR/naked-functions.rs:195:1
|
LL | #[inline(never)]
| ^^^^^^^^^^^^^^^^
@ -320,7 +293,7 @@ LL | #[inline(never)]
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: naked functions cannot be inlined
--> $DIR/naked-functions.rs:215:1
--> $DIR/naked-functions.rs:203:1
|
LL | #[inline]
| ^^^^^^^^^
@ -329,7 +302,7 @@ LL | #[inline]
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: naked functions cannot be inlined
--> $DIR/naked-functions.rs:218:1
--> $DIR/naked-functions.rs:206:1
|
LL | #[inline(always)]
| ^^^^^^^^^^^^^^^^^
@ -338,7 +311,7 @@ LL | #[inline(always)]
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
warning: naked functions cannot be inlined
--> $DIR/naked-functions.rs:221:1
--> $DIR/naked-functions.rs:209:1
|
LL | #[inline(never)]
| ^^^^^^^^^^^^^^^^
@ -346,5 +319,5 @@ LL | #[inline(never)]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #32408 <https://github.com/rust-lang/rust/issues/32408>
error: aborting due to 8 previous errors; 25 warnings emitted
error: aborting due to 8 previous errors; 23 warnings emitted

View File

@ -8,9 +8,6 @@
// check-pass
// dont-check-compiler-stdout - don't check for any AST change.
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
enum V {
A(i32),
B { f: [i64; 3 + 4] }
@ -27,12 +24,6 @@ macro_rules! call_println {
}
fn main() {
#[cfg(any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64"))]
unsafe { llvm_asm!(""::::); }
let x: (i32) = 35;
let y = x as i64<> + 5;

View File

@ -1,83 +0,0 @@
// ignore-s390x
// ignore-emscripten
// ignore-powerpc
// ignore-powerpc64
// ignore-powerpc64le
// ignore-riscv64
// ignore-sparc
// ignore-sparc64
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
#[cfg(any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64",
target_arch = "mips",
target_arch = "mips64"))]
mod test_cases {
fn is_move() {
let y: &mut isize;
let x = &mut 0isize;
unsafe {
llvm_asm!("nop" : : "r"(x));
}
let z = x; //~ ERROR use of moved value: `x`
}
fn in_is_read() {
let mut x = 3;
let y = &mut x;
unsafe {
llvm_asm!("nop" : : "r"(x)); //~ ERROR cannot use
}
let z = y;
}
fn out_is_assign() {
let x = 3;
unsafe {
llvm_asm!("nop" : "=r"(x)); //~ ERROR cannot assign twice
}
let mut a = &mut 3;
let b = &*a;
unsafe {
llvm_asm!("nop" : "=r"(a)); // OK, Shallow write to `a`
}
let c = b;
let d = *a;
}
fn rw_is_assign() {
let x = 3;
unsafe {
llvm_asm!("nop" : "+r"(x)); //~ ERROR cannot assign twice
}
}
fn indirect_is_not_init() {
let x: i32;
unsafe {
llvm_asm!("nop" : "=*r"(x)); //~ ERROR use of possibly-uninitialized variable
}
}
fn rw_is_read() {
let mut x = &mut 3;
let y = &*x;
unsafe {
llvm_asm!("nop" : "+r"(x)); //~ ERROR cannot assign to `x` because it is borrowed
}
let z = y;
}
fn two_moves() {
let x = &mut 2;
unsafe {
llvm_asm!("nop" : : "r"(x), "r"(x) ); //~ ERROR use of moved value
}
}
}
fn main() {}

View File

@ -1,81 +0,0 @@
error[E0382]: use of moved value: `x`
--> $DIR/borrowck-asm.rs:26:17
|
LL | let x = &mut 0isize;
| - move occurs because `x` has type `&mut isize`, which does not implement the `Copy` trait
LL | unsafe {
LL | llvm_asm!("nop" : : "r"(x));
| - value moved here
LL | }
LL | let z = x;
| ^ value used here after move
error[E0503]: cannot use `x` because it was mutably borrowed
--> $DIR/borrowck-asm.rs:33:37
|
LL | let y = &mut x;
| ------ borrow of `x` occurs here
LL | unsafe {
LL | llvm_asm!("nop" : : "r"(x));
| ^ use of borrowed `x`
LL | }
LL | let z = y;
| - borrow later used here
error[E0384]: cannot assign twice to immutable variable `x`
--> $DIR/borrowck-asm.rs:41:36
|
LL | let x = 3;
| -
| |
| first assignment to `x`
| help: consider making this binding mutable: `mut x`
LL | unsafe {
LL | llvm_asm!("nop" : "=r"(x));
| ^ cannot assign twice to immutable variable
error[E0384]: cannot assign twice to immutable variable `x`
--> $DIR/borrowck-asm.rs:55:36
|
LL | let x = 3;
| -
| |
| first assignment to `x`
| help: consider making this binding mutable: `mut x`
LL | unsafe {
LL | llvm_asm!("nop" : "+r"(x));
| ^ cannot assign twice to immutable variable
error[E0381]: use of possibly-uninitialized variable: `x`
--> $DIR/borrowck-asm.rs:62:37
|
LL | llvm_asm!("nop" : "=*r"(x));
| ^ use of possibly-uninitialized `x`
error[E0506]: cannot assign to `x` because it is borrowed
--> $DIR/borrowck-asm.rs:70:36
|
LL | let y = &*x;
| --- borrow of `x` occurs here
LL | unsafe {
LL | llvm_asm!("nop" : "+r"(x));
| ^ assignment to borrowed `x` occurs here
LL | }
LL | let z = y;
| - borrow later used here
error[E0382]: use of moved value: `x`
--> $DIR/borrowck-asm.rs:78:45
|
LL | let x = &mut 2;
| - move occurs because `x` has type `&mut i32`, which does not implement the `Copy` trait
LL | unsafe {
LL | llvm_asm!("nop" : : "r"(x), "r"(x) );
| - ^ value used here after move
| |
| value moved here
error: aborting due to 7 previous errors
Some errors have detailed explanations: E0381, E0382, E0384, E0503, E0506.
For more information about an error, try `rustc --explain E0381`.

View File

@ -1,24 +1,13 @@
// compile-flags: -Zunleash-the-miri-inside-of-you
// only-x86_64
#![feature(llvm_asm)]
#![allow(const_err)]
#![allow(deprecated)] // llvm_asm!
use std::arch::asm;
fn main() {}
// Make sure we catch executing inline assembly.
static TEST_BAD1: () = {
unsafe { llvm_asm!("xor %eax, %eax" ::: "eax"); }
//~^ ERROR could not evaluate static initializer
//~| NOTE inline assembly is not supported
//~| NOTE in this expansion of llvm_asm!
//~| NOTE in this expansion of llvm_asm!
};
// Make sure we catch executing inline assembly.
static TEST_BAD2: () = {
static TEST_BAD: () = {
unsafe { asm!("nop"); }
//~^ ERROR could not evaluate static initializer
//~| NOTE inline assembly is not supported

View File

@ -1,13 +1,5 @@
error[E0080]: could not evaluate static initializer
--> $DIR/inline_asm.rs:13:14
|
LL | unsafe { llvm_asm!("xor %eax, %eax" ::: "eax"); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ inline assembly is not supported
|
= note: this error originates in the macro `llvm_asm` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: could not evaluate static initializer
--> $DIR/inline_asm.rs:22:14
--> $DIR/inline_asm.rs:11:14
|
LL | unsafe { asm!("nop"); }
| ^^^^^^^^^^^ inline assembly is not supported
@ -15,17 +7,11 @@ LL | unsafe { asm!("nop"); }
warning: skipping const checks
|
help: skipping check that does not even have a feature gate
--> $DIR/inline_asm.rs:13:14
|
LL | unsafe { llvm_asm!("xor %eax, %eax" ::: "eax"); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
--> $DIR/inline_asm.rs:22:14
--> $DIR/inline_asm.rs:11:14
|
LL | unsafe { asm!("nop"); }
| ^^^^^^^^^^^
= note: this warning originates in the macro `llvm_asm` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors; 1 warning emitted
error: aborting due to previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0080`.

View File

@ -1,10 +0,0 @@
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
fn main() {
let a;
llvm_asm!("nop" "nop");
//~^ ERROR E0660
llvm_asm!("nop" "nop" : "=r"(a));
//~^ ERROR E0660
}

View File

@ -1,15 +0,0 @@
error[E0660]: malformed inline assembly
--> $DIR/E0660.rs:6:5
|
LL | llvm_asm!("nop" "nop");
| ^^^^^^^^^^^^^^^^^^^^^^
error[E0660]: malformed inline assembly
--> $DIR/E0660.rs:8:5
|
LL | llvm_asm!("nop" "nop" : "=r"(a));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0660`.

View File

@ -1,10 +0,0 @@
// ignore-emscripten
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
fn main() {
let a; //~ ERROR type annotations needed
llvm_asm!("nop" : "r"(a));
//~^ ERROR E0661
}

View File

@ -1,16 +0,0 @@
error[E0661]: output operand constraint lacks '=' or '+'
--> $DIR/E0661.rs:8:23
|
LL | llvm_asm!("nop" : "r"(a));
| ^^^
error[E0282]: type annotations needed
--> $DIR/E0661.rs:7:9
|
LL | let a;
| ^ consider giving `a` a type
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0282, E0661.
For more information about an error, try `rustc --explain E0282`.

View File

@ -1,11 +0,0 @@
// ignore-emscripten
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
fn main() {
llvm_asm!("xor %eax, %eax"
:
: "=test"("a") //~ ERROR E0662
);
}

View File

@ -1,9 +0,0 @@
error[E0662]: input operand constraint contains '='
--> $DIR/E0662.rs:9:17
|
LL | : "=test"("a")
| ^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0662`.

View File

@ -1,11 +0,0 @@
// ignore-emscripten
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
fn main() {
llvm_asm!("xor %eax, %eax"
:
: "+test"("a") //~ ERROR E0663
);
}

View File

@ -1,9 +0,0 @@
error[E0663]: input operand constraint contains '+'
--> $DIR/E0663.rs:9:17
|
LL | : "+test"("a")
| ^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0663`.

View File

@ -1,12 +0,0 @@
// ignore-emscripten
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
fn main() {
llvm_asm!("mov $$0x200, %eax"
:
:
: "{eax}" //~ ERROR E0664
);
}

View File

@ -1,9 +0,0 @@
error[E0664]: clobber should not be surrounded by braces
--> $DIR/E0664.rs:10:17
|
LL | : "{eax}"
| ^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0664`.

View File

@ -1,10 +0,0 @@
// only-x86_64
#![allow(deprecated)] // llvm_asm!
fn main() {
unsafe {
llvm_asm!("");
//~^ ERROR prefer using the new asm! syntax instead
}
}

View File

@ -1,12 +0,0 @@
error[E0658]: use of unstable library feature 'llvm_asm': prefer using the new asm! syntax instead
--> $DIR/feature-gate-asm.rs:7:9
|
LL | llvm_asm!("");
| ^^^^^^^^
|
= note: see issue #70173 <https://github.com/rust-lang/rust/issues/70173> for more information
= help: add `#![feature(llvm_asm)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,10 +0,0 @@
// only-x86_64
#![allow(deprecated)] // llvm_asm!
fn main() {
unsafe {
println!("{:?}", llvm_asm!(""));
//~^ ERROR prefer using the new asm! syntax instead
}
}

View File

@ -1,12 +0,0 @@
error[E0658]: use of unstable library feature 'llvm_asm': prefer using the new asm! syntax instead
--> $DIR/feature-gate-asm2.rs:7:26
|
LL | println!("{:?}", llvm_asm!(""));
| ^^^^^^^^
|
= note: see issue #70173 <https://github.com/rust-lang/rust/issues/70173> for more information
= help: add `#![feature(llvm_asm)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.

View File

@ -2,7 +2,6 @@
#![allow(dead_code)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(deprecated)] // llvm_asm!
// ignore-pretty unreported
#![feature(box_syntax)]
@ -13,7 +12,6 @@ impl bomb for S { fn boom(&self, _: Ident) { } }
pub struct Ident { name: usize }
// macro_rules! int3 { () => ( unsafe { llvm_asm!( "int3" ); } ) }
macro_rules! int3 { () => ( { } ) }
fn Ident_new() -> Ident {

View File

@ -1,13 +0,0 @@
// build-fail
// dont-check-compiler-stderr
// compile-flags: -C codegen-units=2
// ignore-emscripten
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
fn main() {
unsafe {
llvm_asm!("nowayisthisavalidinstruction"); //~ ERROR instruction
}
}

View File

@ -1,12 +0,0 @@
// build-fail
// dont-check-compiler-stderr
// ignore-emscripten
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
fn main() {
unsafe {
llvm_asm!("nowayisthisavalidinstruction"); //~ ERROR instruction
}
}

View File

@ -1,41 +0,0 @@
// Test that the compiler will catch invalid inline assembly constraints.
// build-fail
// ignore-emscripten
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
extern "C" {
fn foo(a: usize);
}
fn main() {
bad_register_constraint();
bad_input();
wrong_size_output();
}
// Issue #54130
fn bad_register_constraint() {
let rax: u64;
unsafe {
llvm_asm!("" :"={rax"(rax)) //~ ERROR E0668
};
println!("Accumulator is: {}", rax);
}
// Issue #54376
fn bad_input() {
unsafe {
llvm_asm!("callq $0" : : "0"(foo)) //~ ERROR E0668
};
}
fn wrong_size_output() {
let rax: u64 = 0;
unsafe {
llvm_asm!("addb $1, $0" : "={rax}"((0i32, rax))); //~ ERROR E0668
}
println!("rax: {}", rax);
}

View File

@ -1,27 +0,0 @@
error[E0668]: malformed inline assembly
--> $DIR/inline-asm-bad-constraint.rs:23:9
|
LL | llvm_asm!("" :"={rax"(rax))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `llvm_asm` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0668]: malformed inline assembly
--> $DIR/inline-asm-bad-constraint.rs:31:9
|
LL | llvm_asm!("callq $0" : : "0"(foo))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `llvm_asm` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0668]: malformed inline assembly
--> $DIR/inline-asm-bad-constraint.rs:38:9
|
LL | llvm_asm!("addb $1, $0" : "={rax}"((0i32, rax)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `llvm_asm` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0668`.

View File

@ -1,60 +0,0 @@
// Test that the compiler will catch passing invalid values to inline assembly
// operands.
// build-fail
// ignore-emscripten
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
#[repr(C)]
struct MyPtr(usize);
fn main() {
issue_37433();
issue_37437();
issue_40187();
issue_54067();
multiple_errors();
}
fn issue_37433() {
unsafe {
llvm_asm!("" :: "r"("")); //~ ERROR E0669
}
unsafe {
let target = MyPtr(0);
llvm_asm!("ret" : : "{rdi}"(target)); //~ ERROR E0669
}
}
fn issue_37437() {
let hello: &str = "hello";
// this should fail...
unsafe { llvm_asm!("" :: "i"(hello)) }; //~ ERROR E0669
// but this should succeed.
unsafe { llvm_asm!("" :: "r"(hello.as_ptr())) };
}
fn issue_40187() {
let arr: [u8; 1] = [0; 1];
unsafe {
llvm_asm!("movups $1, %xmm0"::"m"(arr)); //~ ERROR E0669
}
}
fn issue_54067() {
let addr: Option<u32> = Some(123);
unsafe {
llvm_asm!("mov sp, $0"::"r"(addr)); //~ ERROR E0669
}
}
fn multiple_errors() {
let addr: (u32, u32) = (1, 2);
unsafe {
llvm_asm!("mov sp, $0"::"r"(addr), //~ ERROR E0669
"r"("hello e0669")); //~ ERROR E0669
}
}

View File

@ -1,45 +0,0 @@
error[E0669]: invalid value for constraint in inline assembly
--> $DIR/inline-asm-bad-operand.rs:23:29
|
LL | llvm_asm!("" :: "r"(""));
| ^^
error[E0669]: invalid value for constraint in inline assembly
--> $DIR/inline-asm-bad-operand.rs:28:37
|
LL | llvm_asm!("ret" : : "{rdi}"(target));
| ^^^^^^
error[E0669]: invalid value for constraint in inline assembly
--> $DIR/inline-asm-bad-operand.rs:35:34
|
LL | unsafe { llvm_asm!("" :: "i"(hello)) };
| ^^^^^
error[E0669]: invalid value for constraint in inline assembly
--> $DIR/inline-asm-bad-operand.rs:43:43
|
LL | llvm_asm!("movups $1, %xmm0"::"m"(arr));
| ^^^
error[E0669]: invalid value for constraint in inline assembly
--> $DIR/inline-asm-bad-operand.rs:50:37
|
LL | llvm_asm!("mov sp, $0"::"r"(addr));
| ^^^^
error[E0669]: invalid value for constraint in inline assembly
--> $DIR/inline-asm-bad-operand.rs:57:37
|
LL | llvm_asm!("mov sp, $0"::"r"(addr),
| ^^^^
error[E0669]: invalid value for constraint in inline assembly
--> $DIR/inline-asm-bad-operand.rs:58:37
|
LL | ... "r"("hello e0669"));
| ^^^^^^^^^^^^^
error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0669`.

View File

@ -1,49 +0,0 @@
// build-pass
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(deprecated)] // llvm_asm!
#![feature(llvm_asm)]
type History = Vec<&'static str>;
fn wrap<A>(x:A, which: &'static str, history: &mut History) -> A {
history.push(which);
x
}
macro_rules! demo {
( $output_constraint:tt ) => {
{
let mut x: isize = 0;
let y: isize = 1;
let mut history: History = vec![];
unsafe {
llvm_asm!("mov ($1), $0"
: $output_constraint (*wrap(&mut x, "out", &mut history))
: "r"(&wrap(y, "in", &mut history))
:: "volatile");
}
assert_eq!((x,y), (1,1));
let b: &[_] = &["out", "in"];
assert_eq!(history, b);
}
}
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn main() {
fn out_write_only_expr_then_in_expr() {
demo!("=r")
}
fn out_read_write_expr_then_in_expr() {
demo!("+r")
}
out_write_only_expr_then_in_expr();
out_read_write_expr_then_in_expr();
}
#[cfg(all(not(target_arch = "x86"), not(target_arch = "x86_64")))]
pub fn main() {}

View File

@ -1,12 +0,0 @@
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
// compile-flags: -Ccodegen-units=1
// build-fail
// only-x86_64
fn main() {
unsafe {
llvm_asm!("int $3"); //~ ERROR too few operands for instruction
//~| ERROR invalid operand in inline asm
}
}

View File

@ -1,20 +0,0 @@
error: invalid operand in inline asm: 'int $3'
--> $DIR/issue-23458.rs:9:9
|
LL | llvm_asm!("int $3");
| ^
error: too few operands for instruction
--> $DIR/issue-23458.rs:9:9
|
LL | llvm_asm!("int $3");
| ^
|
note: instantiated into assembly here
--> <inline asm>:1:2
|
LL | int
| ^
error: aborting due to 2 previous errors

View File

@ -1,30 +0,0 @@
// build-pass
// only-x86_64
#![allow(dead_code, non_upper_case_globals)]
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
#[repr(C)]
pub struct D32x4(f32,f32,f32,f32);
impl D32x4 {
fn add(&self, vec: Self) -> Self {
unsafe {
let ret: Self;
llvm_asm!("
movaps $1, %xmm1
movaps $2, %xmm2
addps %xmm1, %xmm2
movaps $xmm1, $0
"
: "=r"(ret)
: "1"(self), "2"(vec)
: "xmm1", "xmm2"
);
ret
}
}
}
fn main() { }

View File

@ -1,16 +0,0 @@
// check-pass
// ignore-emscripten
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
macro_rules! interrupt_handler {
() => {
unsafe fn _interrupt_handler() {
llvm_asm!("pop eax" :::: "intel");
}
}
}
interrupt_handler!{}
fn main() {}

View File

@ -1,12 +0,0 @@
// build-fail
// ignore-emscripten no llvm_asm! support
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
fn main() {
unsafe {
llvm_asm!("" :: "r"(""));
//~^ ERROR: invalid value for constraint in inline assembly
}
}

View File

@ -1,9 +0,0 @@
error[E0669]: invalid value for constraint in inline assembly
--> $DIR/issue-37433.rs:9:29
|
LL | llvm_asm!("" :: "r"(""));
| ^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0669`.

View File

@ -1,12 +0,0 @@
// build-fail
// ignore-emscripten no llvm_asm! support
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
fn main() {
unsafe {
llvm_asm! {"mov $0,$1"::"0"("bx"),"1"(0x00)}
//~^ ERROR: invalid value for constraint in inline assembly
}
}

View File

@ -1,9 +0,0 @@
error[E0669]: invalid value for constraint in inline assembly
--> $DIR/issue-51431.rs:9:37
|
LL | llvm_asm! {"mov $0,$1"::"0"("bx"),"1"(0x00)}
| ^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0669`.

View File

@ -1,27 +0,0 @@
// Regression test for Issue #53787: Fix ICE when creating a label in inline assembler with macros.
// build-fail
// ignore-emscripten
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
macro_rules! fake_jump {
($id:expr) => {
unsafe {
llvm_asm!(
"
jmp $0
lea eax, [ebx]
xor eax, 0xDEADBEEF
retn
$0:
"::"0"($id)::"volatile", "intel");
}
};
}
fn main() {
fake_jump!("FirstFunc"); //~ ERROR invalid value for constraint in inline assembly
println!("Hello, world!");
}

View File

@ -1,9 +0,0 @@
error[E0669]: invalid value for constraint in inline assembly
--> $DIR/issue-53787-inline-assembler-macro.rs:25:16
|
LL | fake_jump!("FirstFunc");
| ^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0669`.

View File

@ -1,13 +0,0 @@
// check-pass
// ignore-emscripten no llvm_asm! support
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
pub fn boot(addr: Option<u32>) {
unsafe {
llvm_asm!("mov sp, $0"::"r" (addr));
}
}
fn main() {}

View File

@ -1,12 +0,0 @@
// build-fail
// ignore-emscripten no asm! support
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
fn main() {
unsafe {
llvm_asm!("nop" : "+r"("r15"));
//~^ malformed inline assembly
}
}

View File

@ -1,11 +0,0 @@
error[E0668]: malformed inline assembly
--> $DIR/issue-62046.rs:9:9
|
LL | llvm_asm!("nop" : "+r"("r15"));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `llvm_asm` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
For more information about this error, try `rustc --explain E0668`.

View File

@ -1,13 +0,0 @@
// build-fail
// ignore-emscripten no asm! support
// The error message differs slightly between LLVM versions
// min-llvm-version: 13.0
// Regression test for #69092
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
fn main() {
unsafe { llvm_asm!(".ascii \"Xen\0\""); }
//~^ ERROR: expected string
}

View File

@ -1,14 +0,0 @@
error: expected string
--> $DIR/issue-69092.rs:11:14
|
LL | unsafe { llvm_asm!(".ascii \"Xen\0\""); }
| ^
|
note: instantiated into assembly here
--> <inline asm>:1:9
|
LL | .ascii "Xen
| ^
error: aborting due to previous error

View File

@ -1,27 +0,0 @@
// ignore-android
// ignore-arm
// ignore-aarch64
// ignore-s390x
// ignore-emscripten
// ignore-powerpc
// ignore-powerpc64
// ignore-powerpc64le
// ignore-riscv64
// ignore-sparc
// ignore-sparc64
// ignore-mips
// ignore-mips64
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
#[cfg(any(target_arch = "x86",
target_arch = "x86_64"))]
pub fn main() {
unsafe {
// clobber formatted as register input/output
llvm_asm!("xor %eax, %eax" : : : "{eax}");
//~^ ERROR clobber should not be surrounded by braces
}
}

View File

@ -1,9 +0,0 @@
error[E0664]: clobber should not be surrounded by braces
--> $DIR/llvm-asm-bad-clobber.rs:24:42
|
LL | llvm_asm!("xor %eax, %eax" : : : "{eax}");
| ^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0664`.

View File

@ -1,10 +0,0 @@
// run-pass
// pretty-expanded FIXME #23616
// ignore-emscripten no asm
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
pub fn main() {
unsafe { llvm_asm!(concat!("", "")) };
}

View File

@ -1,36 +0,0 @@
// ignore-s390x
// ignore-emscripten
// ignore-powerpc
// ignore-powerpc64
// ignore-powerpc64le
// ignore-riscv64
// ignore-sparc
// ignore-sparc64
// ignore-mips
// ignore-mips64
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
fn foo(x: isize) { println!("{}", x); }
#[cfg(any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64"))]
pub fn main() {
let x: isize;
let y: isize;
unsafe {
llvm_asm!("mov $1, $0" : "=r"(x) : "=r"(5)); //~ ERROR operand constraint contains '='
llvm_asm!("mov $1, $0" : "=r"(y) : "+r"(5)); //~ ERROR operand constraint contains '+'
}
foo(x);
foo(y);
}
#[cfg(not(any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64")))]
pub fn main() {}

View File

@ -1,16 +0,0 @@
error[E0662]: input operand constraint contains '='
--> $DIR/llvm-asm-in-bad-modifier.rs:25:44
|
LL | llvm_asm!("mov $1, $0" : "=r"(x) : "=r"(5));
| ^^^^
error[E0663]: input operand constraint contains '+'
--> $DIR/llvm-asm-in-bad-modifier.rs:26:44
|
LL | llvm_asm!("mov $1, $0" : "=r"(y) : "+r"(5));
| ^^^^
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0662, E0663.
For more information about an error, try `rustc --explain E0662`.

View File

@ -1,32 +0,0 @@
// run-pass
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
#![allow(dead_code)]
use std::cell::Cell;
#[repr(C)]
struct NoisyDrop<'a>(&'a Cell<&'static str>);
impl<'a> Drop for NoisyDrop<'a> {
fn drop(&mut self) {
self.0.set("destroyed");
}
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn main() {
let status = Cell::new("alive");
{
let _y: Box<NoisyDrop>;
let x = Box::new(NoisyDrop(&status));
unsafe {
llvm_asm!("mov $1, $0" : "=r"(_y) : "r"(x));
}
assert_eq!(status.get(), "alive");
}
assert_eq!(status.get(), "destroyed");
}
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
fn main() {}

View File

@ -1,57 +0,0 @@
// run-pass
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
unsafe fn next_power_of_2(n: u32) -> u32 {
let mut tmp = n;
llvm_asm!("dec $0" : "+rm"(tmp) :: "cc");
let mut shift = 1_u32;
while shift <= 16 {
llvm_asm!(
"shr %cl, $2
or $2, $0
shl $$1, $1"
: "+&rm"(tmp), "+{ecx}"(shift) : "r"(tmp) : "cc"
);
}
llvm_asm!("inc $0" : "+rm"(tmp) :: "cc");
return tmp;
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub fn main() {
unsafe {
assert_eq!(64, next_power_of_2(37));
assert_eq!(2147483648, next_power_of_2(2147483647));
}
let mut y: isize = 5;
let x: isize;
unsafe {
// Treat the output as initialization.
llvm_asm!(
"shl $2, $1
add $3, $1
mov $1, $0"
: "=r"(x), "+r"(y) : "i"(3_usize), "ir"(7_usize) : "cc"
);
}
assert_eq!(x, 47);
assert_eq!(y, 47);
let mut x = x + 1;
assert_eq!(x, 48);
unsafe {
// Assignment to mutable.
// Early clobber "&":
// Forbids the use of a single register by both operands.
llvm_asm!("shr $$2, $1; add $1, $0" : "+&r"(x) : "r"(x) : "cc");
}
assert_eq!(x, 60);
}
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
pub fn main() {}

View File

@ -1,44 +0,0 @@
// run-pass
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn read(ptr: &u32) -> u32 {
let out: u32;
unsafe {
llvm_asm!("mov $1, $0" : "=r" (out) : "*m" (ptr));
}
out
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn write(ptr: &mut u32, val: u32) {
unsafe {
llvm_asm!("mov $1, $0" : "=*m" (ptr) : "r" (val));
}
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn replace(ptr: &mut u32, val: u32) -> u32 {
let out: u32;
unsafe {
llvm_asm!("mov $0, $1; mov $2, $0" : "+*m" (ptr), "=&r" (out) : "r" (val));
}
out
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub fn main() {
let a = 1;
assert_eq!(read(&a), 1);
let mut b = 2;
write(&mut b, 3);
assert_eq!(b, 3);
let mut c = 4;
assert_eq!(replace(&mut c, 5), 4);
assert_eq!(c, 5);
}
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
pub fn main() {}

View File

@ -1,13 +0,0 @@
// build-pass
// only-x86_64
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
fn main() {
unsafe {
// "nop" :: "r"(x) : "eax" : "volatile"
let x = 10;
llvm_asm!("\x6Eop" :: "\x72"(x) : "\x65ax" : "\x76olatile");
}
}

View File

@ -1,37 +0,0 @@
// check-pass
// ignore-android
// ignore-arm
// ignore-aarch64
// ignore-s390x
// ignore-emscripten
// ignore-powerpc
// ignore-powerpc64
// ignore-powerpc64le
// ignore-riscv64
// ignore-sparc
// ignore-sparc64
// ignore-mips
// ignore-mips64
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
#[cfg(any(target_arch = "x86",
target_arch = "x86_64"))]
fn main() {
// assignment not dead
let mut x: isize = 0;
unsafe {
// extra colon
llvm_asm!("mov $1, $0" : "=r"(x) : "r"(5_usize), "0"(x) : : "cc");
//~^ WARNING unrecognized option
}
assert_eq!(x, 5);
unsafe {
// comma in place of a colon
llvm_asm!("add $2, $1; mov $1, $0" : "=r"(x) : "r"(x), "r"(8_usize) : "cc", "volatile");
//~^ WARNING expected a clobber, found an option
}
assert_eq!(x, 13);
}

View File

@ -1,14 +0,0 @@
warning: unrecognized option
--> $DIR/llvm-asm-misplaced-option.rs:26:69
|
LL | llvm_asm!("mov $1, $0" : "=r"(x) : "r"(5_usize), "0"(x) : : "cc");
| ^^^^
warning: expected a clobber, found an option
--> $DIR/llvm-asm-misplaced-option.rs:33:85
|
LL | llvm_asm!("add $2, $1; mov $1, $0" : "=r"(x) : "r"(x), "r"(8_usize) : "cc", "volatile");
| ^^^^^^^^^^
warning: 2 warnings emitted

View File

@ -1,36 +0,0 @@
// ignore-s390x
// ignore-emscripten
// ignore-powerpc
// ignore-powerpc64
// ignore-powerpc64le
// ignore-riscv64
// ignore-sparc
// ignore-sparc64
// ignore-mips
// ignore-mips64
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
fn foo(x: isize) { println!("{}", x); }
#[cfg(any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64"))]
pub fn main() {
let x: isize;
x = 1;
foo(x);
unsafe {
llvm_asm!("mov $1, $0" : "=r"(x) : "r"(5));
//~^ ERROR cannot assign twice to immutable variable `x`
}
foo(x);
}
#[cfg(not(any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64")))]
pub fn main() {}

View File

@ -1,14 +0,0 @@
error[E0384]: cannot assign twice to immutable variable `x`
--> $DIR/llvm-asm-out-assign-imm.rs:26:39
|
LL | let x: isize;
| - help: consider making this binding mutable: `mut x`
LL | x = 1;
| ----- first assignment to `x`
...
LL | llvm_asm!("mov $1, $0" : "=r"(x) : "r"(5));
| ^ cannot assign twice to immutable variable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0384`.

View File

@ -1,26 +0,0 @@
// run-pass
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!s
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub fn main() {
let x: isize;
unsafe {
// Treat the output as initialization.
llvm_asm!("mov $1, $0" : "=r"(x) : "r"(5_usize));
}
assert_eq!(x, 5);
let mut x = x + 1;
assert_eq!(x, 6);
unsafe {
// Assignment to mutable.
llvm_asm!("mov $1, $0" : "=r"(x) : "r"(x + 7));
}
assert_eq!(x, 13);
}
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
pub fn main() {}

View File

@ -1,33 +0,0 @@
// ignore-s390x
// ignore-emscripten
// ignore-powerpc
// ignore-powerpc64
// ignore-powerpc64le
// ignore-riscv64
// ignore-sparc
// ignore-sparc64
// ignore-mips
// ignore-mips64
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
fn foo(x: isize) { println!("{}", x); }
#[cfg(any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64"))]
pub fn main() {
let x: isize;
unsafe {
llvm_asm!("mov $1, $0" : "r"(x) : "r"(5)); //~ ERROR output operand constraint lacks '='
}
foo(x);
}
#[cfg(not(any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64")))]
pub fn main() {}

View File

@ -1,9 +0,0 @@
error[E0661]: output operand constraint lacks '=' or '+'
--> $DIR/llvm-asm-out-no-modifier.rs:24:34
|
LL | llvm_asm!("mov $1, $0" : "r"(x) : "r"(5));
| ^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0661`.

View File

@ -1,34 +0,0 @@
// ignore-s390x
// ignore-emscripten
// ignore-powerpc
// ignore-powerpc64
// ignore-powerpc64le
// ignore-riscv64
// ignore-sparc
// ignore-sparc64
// ignore-mips
// ignore-mips64
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
fn foo(x: isize) { println!("{}", x); }
#[cfg(any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64"))]
pub fn main() {
let x: isize;
unsafe {
llvm_asm!("mov $1, $0" : "=r"(x) : "r"(x));
//~^ ERROR use of possibly-uninitialized variable: `x`
}
foo(x);
}
#[cfg(not(any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64")))]
pub fn main() {}

View File

@ -1,9 +0,0 @@
error[E0381]: use of possibly-uninitialized variable: `x`
--> $DIR/llvm-asm-out-read-uninit.rs:24:48
|
LL | llvm_asm!("mov $1, $0" : "=r"(x) : "r"(x));
| ^ use of possibly-uninitialized `x`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0381`.

View File

@ -1,16 +0,0 @@
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
fn main() {
llvm_asm!(); //~ ERROR requires a string literal as an argument
llvm_asm!("nop" : struct); //~ ERROR expected string literal
llvm_asm!("mov %eax, $$0x2" : struct); //~ ERROR expected string literal
llvm_asm!("mov %eax, $$0x2" : "={eax}" struct); //~ ERROR expected `(`
llvm_asm!("mov %eax, $$0x2" : "={eax}"(struct)); //~ ERROR expected expression
llvm_asm!("in %dx, %al" : "={al}"(result) : struct); //~ ERROR expected string literal
llvm_asm!("in %dx, %al" : "={al}"(result) : "{dx}" struct); //~ ERROR expected `(`
llvm_asm!("in %dx, %al" : "={al}"(result) : "{dx}"(struct)); //~ ERROR expected expression
llvm_asm!("mov $$0x200, %eax" : : : struct); //~ ERROR expected string literal
llvm_asm!("mov eax, 2" : "={eax}"(foo) : : : struct); //~ ERROR expected string literal
llvm_asm!(123); //~ ERROR inline assembly must be a string literal
}

View File

@ -1,68 +0,0 @@
error: macro requires a string literal as an argument
--> $DIR/llvm-asm-parse-errors.rs:5:5
|
LL | llvm_asm!();
| ^^^^^^^^^^^ string literal required
error: expected string literal
--> $DIR/llvm-asm-parse-errors.rs:6:23
|
LL | llvm_asm!("nop" : struct);
| ^^^^^^ not a string literal
error: expected string literal
--> $DIR/llvm-asm-parse-errors.rs:7:35
|
LL | llvm_asm!("mov %eax, $$0x2" : struct);
| ^^^^^^ not a string literal
error: expected `(`, found keyword `struct`
--> $DIR/llvm-asm-parse-errors.rs:8:44
|
LL | llvm_asm!("mov %eax, $$0x2" : "={eax}" struct);
| ^^^^^^ expected `(`
error: expected expression, found keyword `struct`
--> $DIR/llvm-asm-parse-errors.rs:9:44
|
LL | llvm_asm!("mov %eax, $$0x2" : "={eax}"(struct));
| ^^^^^^ expected expression
error: expected string literal
--> $DIR/llvm-asm-parse-errors.rs:10:49
|
LL | llvm_asm!("in %dx, %al" : "={al}"(result) : struct);
| ^^^^^^ not a string literal
error: expected `(`, found keyword `struct`
--> $DIR/llvm-asm-parse-errors.rs:11:56
|
LL | llvm_asm!("in %dx, %al" : "={al}"(result) : "{dx}" struct);
| ^^^^^^ expected `(`
error: expected expression, found keyword `struct`
--> $DIR/llvm-asm-parse-errors.rs:12:56
|
LL | llvm_asm!("in %dx, %al" : "={al}"(result) : "{dx}"(struct));
| ^^^^^^ expected expression
error: expected string literal
--> $DIR/llvm-asm-parse-errors.rs:13:41
|
LL | llvm_asm!("mov $$0x200, %eax" : : : struct);
| ^^^^^^ not a string literal
error: expected string literal
--> $DIR/llvm-asm-parse-errors.rs:14:50
|
LL | llvm_asm!("mov eax, 2" : "={eax}"(foo) : : : struct);
| ^^^^^^ not a string literal
error: inline assembly must be a string literal
--> $DIR/llvm-asm-parse-errors.rs:15:15
|
LL | llvm_asm!(123);
| ^^^
error: aborting due to 11 previous errors

View File

@ -3,11 +3,9 @@
// test that errors in a (selection) of macros don't kill compilation
// immediately, so that we get more errors listed at a time.
#![feature(llvm_asm)]
#![feature(trace_macros, concat_idents)]
#![feature(stmt_expr_attributes, arbitrary_enum_discriminant)]
#![feature(derive_default_enum)]
#![allow(deprecated)] // llvm_asm!
use std::arch::asm;

View File

@ -1,41 +1,41 @@
error: the `#[default]` attribute may only be used on unit enum variants
--> $DIR/macros-nonfatal-errors.rs:16:5
--> $DIR/macros-nonfatal-errors.rs:14:5
|
LL | #[default]
| ^^^^^^^^^^
error: the `#[default]` attribute may only be used on unit enum variants
--> $DIR/macros-nonfatal-errors.rs:21:36
--> $DIR/macros-nonfatal-errors.rs:19:36
|
LL | struct DefaultInnerAttrTupleStruct(#[default] ());
| ^^^^^^^^^^
error: the `#[default]` attribute may only be used on unit enum variants
--> $DIR/macros-nonfatal-errors.rs:25:1
--> $DIR/macros-nonfatal-errors.rs:23:1
|
LL | #[default]
| ^^^^^^^^^^
error: the `#[default]` attribute may only be used on unit enum variants
--> $DIR/macros-nonfatal-errors.rs:29:1
--> $DIR/macros-nonfatal-errors.rs:27:1
|
LL | #[default]
| ^^^^^^^^^^
error: the `#[default]` attribute may only be used on unit enum variants
--> $DIR/macros-nonfatal-errors.rs:39:11
--> $DIR/macros-nonfatal-errors.rs:37:11
|
LL | Foo = #[default] 0,
| ^^^^^^^^^^
error: the `#[default]` attribute may only be used on unit enum variants
--> $DIR/macros-nonfatal-errors.rs:40:14
--> $DIR/macros-nonfatal-errors.rs:38:14
|
LL | Bar([u8; #[default] 1]),
| ^^^^^^^^^^
error: no default declared
--> $DIR/macros-nonfatal-errors.rs:45:10
--> $DIR/macros-nonfatal-errors.rs:43:10
|
LL | #[derive(Default)]
| ^^^^^^^
@ -44,7 +44,7 @@ LL | #[derive(Default)]
= note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info)
error: multiple declared defaults
--> $DIR/macros-nonfatal-errors.rs:51:10
--> $DIR/macros-nonfatal-errors.rs:49:10
|
LL | #[derive(Default)]
| ^^^^^^^
@ -62,7 +62,7 @@ LL | Baz,
= note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info)
error: `#[default]` attribute does not accept a value
--> $DIR/macros-nonfatal-errors.rs:63:5
--> $DIR/macros-nonfatal-errors.rs:61:5
|
LL | #[default = 1]
| ^^^^^^^^^^^^^^
@ -70,7 +70,7 @@ LL | #[default = 1]
= help: try using `#[default]`
error: multiple `#[default]` attributes
--> $DIR/macros-nonfatal-errors.rs:71:5
--> $DIR/macros-nonfatal-errors.rs:69:5
|
LL | #[default]
| ---------- `#[default]` used here
@ -81,13 +81,13 @@ LL | Foo,
|
= note: only one `#[default]` attribute is needed
help: try removing this
--> $DIR/macros-nonfatal-errors.rs:70:5
--> $DIR/macros-nonfatal-errors.rs:68:5
|
LL | #[default]
| ^^^^^^^^^^
error: multiple `#[default]` attributes
--> $DIR/macros-nonfatal-errors.rs:81:5
--> $DIR/macros-nonfatal-errors.rs:79:5
|
LL | #[default]
| ---------- `#[default]` used here
@ -99,7 +99,7 @@ LL | Foo,
|
= note: only one `#[default]` attribute is needed
help: try removing these
--> $DIR/macros-nonfatal-errors.rs:78:5
--> $DIR/macros-nonfatal-errors.rs:76:5
|
LL | #[default]
| ^^^^^^^^^^
@ -109,7 +109,7 @@ LL | #[default]
| ^^^^^^^^^^
error: the `#[default]` attribute may only be used on unit enum variants
--> $DIR/macros-nonfatal-errors.rs:88:5
--> $DIR/macros-nonfatal-errors.rs:86:5
|
LL | Foo {},
| ^^^
@ -117,7 +117,7 @@ LL | Foo {},
= help: consider a manual implementation of `Default`
error: default variant must be exhaustive
--> $DIR/macros-nonfatal-errors.rs:96:5
--> $DIR/macros-nonfatal-errors.rs:94:5
|
LL | #[non_exhaustive]
| ----------------- declared `#[non_exhaustive]` here
@ -127,43 +127,37 @@ LL | Foo,
= help: consider a manual implementation of `Default`
error: asm template must be a string literal
--> $DIR/macros-nonfatal-errors.rs:101:10
--> $DIR/macros-nonfatal-errors.rs:99:10
|
LL | asm!(invalid);
| ^^^^^^^
error: inline assembly must be a string literal
--> $DIR/macros-nonfatal-errors.rs:102:15
|
LL | llvm_asm!(invalid);
| ^^^^^^^
error: concat_idents! requires ident args
--> $DIR/macros-nonfatal-errors.rs:104:5
--> $DIR/macros-nonfatal-errors.rs:102:5
|
LL | concat_idents!("not", "idents");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: argument must be a string literal
--> $DIR/macros-nonfatal-errors.rs:106:17
--> $DIR/macros-nonfatal-errors.rs:104:17
|
LL | option_env!(invalid);
| ^^^^^^^
error: expected string literal
--> $DIR/macros-nonfatal-errors.rs:107:10
--> $DIR/macros-nonfatal-errors.rs:105:10
|
LL | env!(invalid);
| ^^^^^^^
error: expected string literal
--> $DIR/macros-nonfatal-errors.rs:108:10
--> $DIR/macros-nonfatal-errors.rs:106:10
|
LL | env!(foo, abr, baz);
| ^^^
error: environment variable `RUST_HOPEFULLY_THIS_DOESNT_EXIST` not defined
--> $DIR/macros-nonfatal-errors.rs:109:5
--> $DIR/macros-nonfatal-errors.rs:107:5
|
LL | env!("RUST_HOPEFULLY_THIS_DOESNT_EXIST");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -171,7 +165,7 @@ LL | env!("RUST_HOPEFULLY_THIS_DOESNT_EXIST");
= note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)
error: format argument must be a string literal
--> $DIR/macros-nonfatal-errors.rs:111:13
--> $DIR/macros-nonfatal-errors.rs:109:13
|
LL | format!(invalid);
| ^^^^^^^
@ -182,19 +176,19 @@ LL | format!("{}", invalid);
| +++++
error: argument must be a string literal
--> $DIR/macros-nonfatal-errors.rs:113:14
--> $DIR/macros-nonfatal-errors.rs:111:14
|
LL | include!(invalid);
| ^^^^^^^
error: argument must be a string literal
--> $DIR/macros-nonfatal-errors.rs:115:18
--> $DIR/macros-nonfatal-errors.rs:113:18
|
LL | include_str!(invalid);
| ^^^^^^^
error: couldn't read $DIR/i'd be quite surprised if a file with this name existed: $FILE_NOT_FOUND_MSG (os error 2)
--> $DIR/macros-nonfatal-errors.rs:116:5
--> $DIR/macros-nonfatal-errors.rs:114:5
|
LL | include_str!("i'd be quite surprised if a file with this name existed");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -202,13 +196,13 @@ LL | include_str!("i'd be quite surprised if a file with this name existed")
= note: this error originates in the macro `include_str` (in Nightly builds, run with -Z macro-backtrace for more info)
error: argument must be a string literal
--> $DIR/macros-nonfatal-errors.rs:117:20
--> $DIR/macros-nonfatal-errors.rs:115:20
|
LL | include_bytes!(invalid);
| ^^^^^^^
error: couldn't read $DIR/i'd be quite surprised if a file with this name existed: $FILE_NOT_FOUND_MSG (os error 2)
--> $DIR/macros-nonfatal-errors.rs:118:5
--> $DIR/macros-nonfatal-errors.rs:116:5
|
LL | include_bytes!("i'd be quite surprised if a file with this name existed");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -216,10 +210,16 @@ LL | include_bytes!("i'd be quite surprised if a file with this name existed
= note: this error originates in the macro `include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info)
error: trace_macros! accepts only `true` or `false`
--> $DIR/macros-nonfatal-errors.rs:120:5
--> $DIR/macros-nonfatal-errors.rs:118:5
|
LL | trace_macros!(invalid);
| ^^^^^^^^^^^^^^^^^^^^^^
error: cannot find macro `llvm_asm` in this scope
--> $DIR/macros-nonfatal-errors.rs:100:5
|
LL | llvm_asm!(invalid);
| ^^^^^^^^
error: aborting due to 27 previous errors

View File

@ -2,7 +2,6 @@
#![allow(unused_must_use)]
#![allow(unconditional_recursion)]
#![allow(deprecated)] // llvm_asm!
// ignore-android: FIXME (#20004)
// ignore-emscripten no processes
// ignore-sgx no processes

View File

@ -1,20 +1,11 @@
error[E0133]: use of inline assembly is unsafe and requires unsafe function or block
--> $DIR/inline_asm.rs:11:5
--> $DIR/inline_asm.rs:8:5
|
LL | asm!("nop");
| ^^^^^^^^^^^ use of inline assembly
|
= note: inline assembly is entirely unchecked and can cause undefined behavior
error[E0133]: use of inline assembly is unsafe and requires unsafe function or block
--> $DIR/inline_asm.rs:12:5
|
LL | llvm_asm!("nop");
| ^^^^^^^^^^^^^^^^ use of inline assembly
|
= note: inline assembly is entirely unchecked and can cause undefined behavior
= note: this error originates in the macro `llvm_asm` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
error: aborting due to previous error
For more information about this error, try `rustc --explain E0133`.

View File

@ -2,12 +2,8 @@
// [thir]compile-flags: -Z thir-unsafeck
// needs-asm-support
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
use std::arch::asm;
fn main() {
asm!("nop"); //~ ERROR use of inline assembly is unsafe and requires unsafe function or block
llvm_asm!("nop"); //~ ERROR use of inline assembly is unsafe and requires unsafe function or block
}

View File

@ -1,20 +1,11 @@
error[E0133]: use of inline assembly is unsafe and requires unsafe function or block
--> $DIR/inline_asm.rs:11:5
--> $DIR/inline_asm.rs:8:5
|
LL | asm!("nop");
| ^^^^^^^^^^^ use of inline assembly
|
= note: inline assembly is entirely unchecked and can cause undefined behavior
error[E0133]: use of inline assembly is unsafe and requires unsafe function or block
--> $DIR/inline_asm.rs:12:5
|
LL | llvm_asm!("nop");
| ^^^^^^^^^^^^^^^^ use of inline assembly
|
= note: inline assembly is entirely unchecked and can cause undefined behavior
= note: this error originates in the macro `llvm_asm` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
error: aborting due to previous error
For more information about this error, try `rustc --explain E0133`.