separate test file for invalid sym operand
This commit is contained in:
parent
be66415e11
commit
b73077e3d8
@ -15,15 +15,6 @@ fn main() {
|
||||
unsafe {
|
||||
// Inputs must be initialized
|
||||
|
||||
// Sym operands must point to a function or static
|
||||
|
||||
const C: i32 = 0;
|
||||
static S: i32 = 0;
|
||||
asm!("{}", sym S);
|
||||
asm!("{}", sym main);
|
||||
asm!("{}", sym C);
|
||||
//~^ ERROR invalid `sym` operand
|
||||
|
||||
// Register operands must be Copy
|
||||
|
||||
asm!("{:v}", in(vreg) SimdNonCopy(0.0, 0.0, 0.0, 0.0));
|
||||
@ -65,12 +56,3 @@ fn main() {
|
||||
asm!("{}", in(reg) u);
|
||||
}
|
||||
}
|
||||
|
||||
// Sym operands must point to a function or static
|
||||
|
||||
const C: i32 = 0;
|
||||
static S: i32 = 0;
|
||||
global_asm!("{}", sym S);
|
||||
global_asm!("{}", sym main);
|
||||
global_asm!("{}", sym C);
|
||||
//~^ ERROR invalid `sym` operand
|
||||
|
@ -1,29 +1,13 @@
|
||||
error: invalid `sym` operand
|
||||
--> $DIR/type-check-2.rs:75:19
|
||||
|
|
||||
LL | global_asm!("{}", sym C);
|
||||
| ^^^^^ is an `i32`
|
||||
|
|
||||
= help: `sym` operands must refer to either a function or a static
|
||||
|
||||
error: invalid `sym` operand
|
||||
--> $DIR/type-check-2.rs:24:20
|
||||
|
|
||||
LL | asm!("{}", sym C);
|
||||
| ^^^^^ is an `i32`
|
||||
|
|
||||
= help: `sym` operands must refer to either a function or a static
|
||||
|
||||
error: arguments for inline assembly must be copyable
|
||||
--> $DIR/type-check-2.rs:29:31
|
||||
--> $DIR/type-check-2.rs:20:31
|
||||
|
|
||||
LL | asm!("{:v}", in(vreg) SimdNonCopy(0.0, 0.0, 0.0, 0.0));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `SimdNonCopy` does not implement the Copy trait
|
||||
|
||||
error: cannot use value of type `{closure@$DIR/type-check-2.rs:41:28: 41:36}` for inline assembly
|
||||
--> $DIR/type-check-2.rs:41:28
|
||||
error: cannot use value of type `{closure@$DIR/type-check-2.rs:32:28: 32:36}` for inline assembly
|
||||
--> $DIR/type-check-2.rs:32:28
|
||||
|
|
||||
LL | asm!("{}", in(reg) |x: i32| x);
|
||||
| ^^^^^^^^^^
|
||||
@ -31,7 +15,7 @@ LL | asm!("{}", in(reg) |x: i32| x);
|
||||
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
|
||||
|
||||
error: cannot use value of type `Vec<i32>` for inline assembly
|
||||
--> $DIR/type-check-2.rs:43:28
|
||||
--> $DIR/type-check-2.rs:34:28
|
||||
|
|
||||
LL | asm!("{}", in(reg) vec![0]);
|
||||
| ^^^^^^^
|
||||
@ -40,7 +24,7 @@ LL | asm!("{}", in(reg) vec![0]);
|
||||
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: cannot use value of type `(i32, i32, i32)` for inline assembly
|
||||
--> $DIR/type-check-2.rs:45:28
|
||||
--> $DIR/type-check-2.rs:36:28
|
||||
|
|
||||
LL | asm!("{}", in(reg) (1, 2, 3));
|
||||
| ^^^^^^^^^
|
||||
@ -48,7 +32,7 @@ LL | asm!("{}", in(reg) (1, 2, 3));
|
||||
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
|
||||
|
||||
error: cannot use value of type `[i32; 3]` for inline assembly
|
||||
--> $DIR/type-check-2.rs:47:28
|
||||
--> $DIR/type-check-2.rs:38:28
|
||||
|
|
||||
LL | asm!("{}", in(reg) [1, 2, 3]);
|
||||
| ^^^^^^^^^
|
||||
@ -56,7 +40,7 @@ LL | asm!("{}", in(reg) [1, 2, 3]);
|
||||
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
|
||||
|
||||
error: cannot use value of type `fn() {main}` for inline assembly
|
||||
--> $DIR/type-check-2.rs:55:31
|
||||
--> $DIR/type-check-2.rs:46:31
|
||||
|
|
||||
LL | asm!("{}", inout(reg) f);
|
||||
| ^
|
||||
@ -64,12 +48,12 @@ LL | asm!("{}", inout(reg) f);
|
||||
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
|
||||
|
||||
error: cannot use value of type `&mut i32` for inline assembly
|
||||
--> $DIR/type-check-2.rs:58:31
|
||||
--> $DIR/type-check-2.rs:49:31
|
||||
|
|
||||
LL | asm!("{}", inout(reg) r);
|
||||
| ^
|
||||
|
|
||||
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
|
30
tests/ui/asm/invalid-sym-operand.rs
Normal file
30
tests/ui/asm/invalid-sym-operand.rs
Normal file
@ -0,0 +1,30 @@
|
||||
use std::arch::{asm, global_asm};
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
// Sym operands must point to a function or static
|
||||
|
||||
let x: u64 = 0;
|
||||
const C: i32 = 0;
|
||||
static S: i32 = 0;
|
||||
asm!("{}", sym S);
|
||||
asm!("{}", sym main);
|
||||
asm!("{}", sym C);
|
||||
//~^ ERROR invalid `sym` operand
|
||||
asm!("{}", sym x);
|
||||
//~^ ERROR invalid `sym` operand
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn generic<T>() {
|
||||
asm!("{}", sym generic::<T>);
|
||||
}
|
||||
|
||||
// Sym operands must point to a function or static
|
||||
|
||||
const C: i32 = 0;
|
||||
static S: i32 = 0;
|
||||
global_asm!("{}", sym S);
|
||||
global_asm!("{}", sym main);
|
||||
global_asm!("{}", sym C);
|
||||
//~^ ERROR invalid `sym` operand
|
26
tests/ui/asm/invalid-sym-operand.stderr
Normal file
26
tests/ui/asm/invalid-sym-operand.stderr
Normal file
@ -0,0 +1,26 @@
|
||||
error: invalid `sym` operand
|
||||
--> $DIR/invalid-sym-operand.rs:14:24
|
||||
|
|
||||
LL | asm!("{}", sym x);
|
||||
| ^ is a local variable
|
||||
|
|
||||
= help: `sym` operands must refer to either a function or a static
|
||||
|
||||
error: invalid `sym` operand
|
||||
--> $DIR/invalid-sym-operand.rs:12:20
|
||||
|
|
||||
LL | asm!("{}", sym C);
|
||||
| ^^^^^ is an `i32`
|
||||
|
|
||||
= help: `sym` operands must refer to either a function or a static
|
||||
|
||||
error: invalid `sym` operand
|
||||
--> $DIR/invalid-sym-operand.rs:29:19
|
||||
|
|
||||
LL | global_asm!("{}", sym C);
|
||||
| ^^^^^ is an `i32`
|
||||
|
|
||||
= help: `sym` operands must refer to either a function or a static
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
@ -46,8 +46,6 @@ const fn const_bar<T>(x: T) -> T {
|
||||
asm!("{}", const const_bar(0));
|
||||
asm!("{}", const const_bar(x));
|
||||
//~^ ERROR attempt to use a non-constant value in a constant
|
||||
asm!("{}", sym x);
|
||||
//~^ ERROR invalid `sym` operand
|
||||
|
||||
// Const operands must be integers and must be constants.
|
||||
|
||||
@ -64,10 +62,6 @@ const fn const_bar<T>(x: T) -> T {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn generic<T>() {
|
||||
asm!("{}", sym generic::<T>);
|
||||
}
|
||||
|
||||
// Const operands must be integers and must be constants.
|
||||
|
||||
global_asm!("{}", const 0);
|
||||
|
@ -31,14 +31,6 @@ help: consider using `const` instead of `let`
|
||||
LL | const x: /* Type */ = 0;
|
||||
| ~~~~~ ++++++++++++
|
||||
|
||||
error: invalid `sym` operand
|
||||
--> $DIR/type-check-1.rs:49:24
|
||||
|
|
||||
LL | asm!("{}", sym x);
|
||||
| ^ is a local variable
|
||||
|
|
||||
= help: `sym` operands must refer to either a function or a static
|
||||
|
||||
error: invalid asm output
|
||||
--> $DIR/type-check-1.rs:14:29
|
||||
|
|
||||
@ -103,7 +95,7 @@ LL | asm!("{}", inout(reg) v[..]);
|
||||
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
|
||||
|
||||
error: invalid type for `const` operand
|
||||
--> $DIR/type-check-1.rs:57:20
|
||||
--> $DIR/type-check-1.rs:55:20
|
||||
|
|
||||
LL | asm!("{}", const 0f32);
|
||||
| ^^^^^^----
|
||||
@ -113,7 +105,7 @@ LL | asm!("{}", const 0f32);
|
||||
= help: `const` operands must be of an integer type
|
||||
|
||||
error: invalid type for `const` operand
|
||||
--> $DIR/type-check-1.rs:59:20
|
||||
--> $DIR/type-check-1.rs:57:20
|
||||
|
|
||||
LL | asm!("{}", const 0 as *mut u8);
|
||||
| ^^^^^^------------
|
||||
@ -123,7 +115,7 @@ LL | asm!("{}", const 0 as *mut u8);
|
||||
= help: `const` operands must be of an integer type
|
||||
|
||||
error: invalid type for `const` operand
|
||||
--> $DIR/type-check-1.rs:62:20
|
||||
--> $DIR/type-check-1.rs:60:20
|
||||
|
|
||||
LL | asm!("{}", const &0);
|
||||
| ^^^^^^--
|
||||
@ -133,7 +125,7 @@ LL | asm!("{}", const &0);
|
||||
= help: `const` operands must be of an integer type
|
||||
|
||||
error: invalid type for `const` operand
|
||||
--> $DIR/type-check-1.rs:76:19
|
||||
--> $DIR/type-check-1.rs:70:19
|
||||
|
|
||||
LL | global_asm!("{}", const 0f32);
|
||||
| ^^^^^^----
|
||||
@ -143,7 +135,7 @@ LL | global_asm!("{}", const 0f32);
|
||||
= help: `const` operands must be of an integer type
|
||||
|
||||
error: invalid type for `const` operand
|
||||
--> $DIR/type-check-1.rs:78:19
|
||||
--> $DIR/type-check-1.rs:72:19
|
||||
|
|
||||
LL | global_asm!("{}", const 0 as *mut u8);
|
||||
| ^^^^^^------------
|
||||
@ -152,7 +144,7 @@ LL | global_asm!("{}", const 0 as *mut u8);
|
||||
|
|
||||
= help: `const` operands must be of an integer type
|
||||
|
||||
error: aborting due to 17 previous errors
|
||||
error: aborting due to 16 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0435.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
|
@ -27,17 +27,6 @@ fn main() {
|
||||
asm!("{}", out(reg) v[0]);
|
||||
asm!("{}", inout(reg) v[0]);
|
||||
|
||||
// Sym operands must point to a function or static
|
||||
|
||||
const C: i32 = 0;
|
||||
static S: i32 = 0;
|
||||
asm!("{}", sym S);
|
||||
asm!("{}", sym main);
|
||||
asm!("{}", sym C);
|
||||
//~^ ERROR invalid `sym` operand
|
||||
asm!("{}", sym x);
|
||||
//~^ ERROR invalid `sym` operand
|
||||
|
||||
// Register operands must be Copy
|
||||
|
||||
asm!("{}", in(xmm_reg) SimdNonCopy(0.0, 0.0, 0.0, 0.0));
|
||||
@ -79,12 +68,3 @@ fn main() {
|
||||
asm!("{}", in(reg) u);
|
||||
}
|
||||
}
|
||||
|
||||
// Sym operands must point to a function or static
|
||||
|
||||
const C: i32 = 0;
|
||||
static S: i32 = 0;
|
||||
global_asm!("{}", sym S);
|
||||
global_asm!("{}", sym main);
|
||||
global_asm!("{}", sym C);
|
||||
//~^ ERROR invalid `sym` operand
|
||||
|
@ -1,21 +1,13 @@
|
||||
error: invalid `sym` operand
|
||||
--> $DIR/type-check-2.rs:38:24
|
||||
|
|
||||
LL | asm!("{}", sym x);
|
||||
| ^ is a local variable
|
||||
|
|
||||
= help: `sym` operands must refer to either a function or a static
|
||||
|
||||
error: arguments for inline assembly must be copyable
|
||||
--> $DIR/type-check-2.rs:43:32
|
||||
--> $DIR/type-check-2.rs:32:32
|
||||
|
|
||||
LL | asm!("{}", in(xmm_reg) SimdNonCopy(0.0, 0.0, 0.0, 0.0));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `SimdNonCopy` does not implement the Copy trait
|
||||
|
||||
error: cannot use value of type `{closure@$DIR/type-check-2.rs:55:28: 55:36}` for inline assembly
|
||||
--> $DIR/type-check-2.rs:55:28
|
||||
error: cannot use value of type `{closure@$DIR/type-check-2.rs:44:28: 44:36}` for inline assembly
|
||||
--> $DIR/type-check-2.rs:44:28
|
||||
|
|
||||
LL | asm!("{}", in(reg) |x: i32| x);
|
||||
| ^^^^^^^^^^
|
||||
@ -23,7 +15,7 @@ LL | asm!("{}", in(reg) |x: i32| x);
|
||||
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
|
||||
|
||||
error: cannot use value of type `Vec<i32>` for inline assembly
|
||||
--> $DIR/type-check-2.rs:57:28
|
||||
--> $DIR/type-check-2.rs:46:28
|
||||
|
|
||||
LL | asm!("{}", in(reg) vec![0]);
|
||||
| ^^^^^^^
|
||||
@ -32,7 +24,7 @@ LL | asm!("{}", in(reg) vec![0]);
|
||||
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: cannot use value of type `(i32, i32, i32)` for inline assembly
|
||||
--> $DIR/type-check-2.rs:59:28
|
||||
--> $DIR/type-check-2.rs:48:28
|
||||
|
|
||||
LL | asm!("{}", in(reg) (1, 2, 3));
|
||||
| ^^^^^^^^^
|
||||
@ -40,7 +32,7 @@ LL | asm!("{}", in(reg) (1, 2, 3));
|
||||
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
|
||||
|
||||
error: cannot use value of type `[i32; 3]` for inline assembly
|
||||
--> $DIR/type-check-2.rs:61:28
|
||||
--> $DIR/type-check-2.rs:50:28
|
||||
|
|
||||
LL | asm!("{}", in(reg) [1, 2, 3]);
|
||||
| ^^^^^^^^^
|
||||
@ -48,7 +40,7 @@ LL | asm!("{}", in(reg) [1, 2, 3]);
|
||||
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
|
||||
|
||||
error: cannot use value of type `fn() {main}` for inline assembly
|
||||
--> $DIR/type-check-2.rs:69:31
|
||||
--> $DIR/type-check-2.rs:58:31
|
||||
|
|
||||
LL | asm!("{}", inout(reg) f);
|
||||
| ^
|
||||
@ -56,21 +48,13 @@ LL | asm!("{}", inout(reg) f);
|
||||
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
|
||||
|
||||
error: cannot use value of type `&mut i32` for inline assembly
|
||||
--> $DIR/type-check-2.rs:72:31
|
||||
--> $DIR/type-check-2.rs:61:31
|
||||
|
|
||||
LL | asm!("{}", inout(reg) r);
|
||||
| ^
|
||||
|
|
||||
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
|
||||
|
||||
error: invalid `sym` operand
|
||||
--> $DIR/type-check-2.rs:36:20
|
||||
|
|
||||
LL | asm!("{}", sym C);
|
||||
| ^^^^^ is an `i32`
|
||||
|
|
||||
= help: `sym` operands must refer to either a function or a static
|
||||
|
||||
error[E0381]: used binding `x` isn't initialized
|
||||
--> $DIR/type-check-2.rs:15:28
|
||||
|
|
||||
@ -113,15 +97,7 @@ help: consider changing this to be mutable
|
||||
LL | let mut v: Vec<u64> = vec![0, 1, 2];
|
||||
| +++
|
||||
|
||||
error: invalid `sym` operand
|
||||
--> $DIR/type-check-2.rs:89:19
|
||||
|
|
||||
LL | global_asm!("{}", sym C);
|
||||
| ^^^^^ is an `i32`
|
||||
|
|
||||
= help: `sym` operands must refer to either a function or a static
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0381, E0596.
|
||||
For more information about an error, try `rustc --explain E0381`.
|
||||
|
Loading…
Reference in New Issue
Block a user