fix ICE on specific malformed asm clobber_abi
This commit is contained in:
parent
8c74a5d27c
commit
3dc793e625
5 changed files with 184 additions and 96 deletions
|
@ -379,16 +379,12 @@ fn parse_clobber_abi<'a>(p: &mut Parser<'a>, args: &mut AsmArgs) -> PResult<'a,
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut new_abis = Vec::new();
|
let mut new_abis = Vec::new();
|
||||||
loop {
|
while !p.eat(&token::CloseDelim(Delimiter::Parenthesis)) {
|
||||||
match p.parse_str_lit() {
|
match p.parse_str_lit() {
|
||||||
Ok(str_lit) => {
|
Ok(str_lit) => {
|
||||||
new_abis.push((str_lit.symbol_unescaped, str_lit.span));
|
new_abis.push((str_lit.symbol_unescaped, str_lit.span));
|
||||||
}
|
}
|
||||||
Err(opt_lit) => {
|
Err(opt_lit) => {
|
||||||
// If the non-string literal is a closing paren then it's the end of the list and is fine
|
|
||||||
if p.eat(&token::CloseDelim(Delimiter::Parenthesis)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
let span = opt_lit.map_or(p.token.span, |lit| lit.span);
|
let span = opt_lit.map_or(p.token.span, |lit| lit.span);
|
||||||
let mut err =
|
let mut err =
|
||||||
p.sess.span_diagnostic.struct_span_err(span, "expected string literal");
|
p.sess.span_diagnostic.struct_span_err(span, "expected string literal");
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// only-x86_64
|
// needs-asm-support
|
||||||
|
|
||||||
#![feature(asm_const)]
|
#![feature(asm_const)]
|
||||||
|
|
||||||
|
@ -38,6 +38,9 @@ fn main() {
|
||||||
//~^ ERROR expected one of
|
//~^ ERROR expected one of
|
||||||
asm!("{}", options(), const foo);
|
asm!("{}", options(), const foo);
|
||||||
//~^ ERROR attempt to use a non-constant value in a constant
|
//~^ ERROR attempt to use a non-constant value in a constant
|
||||||
|
|
||||||
|
// test that asm!'s clobber_abi doesn't accept non-string literals
|
||||||
|
// see also https://github.com/rust-lang/rust/issues/112635
|
||||||
asm!("", clobber_abi());
|
asm!("", clobber_abi());
|
||||||
//~^ ERROR at least one abi must be provided
|
//~^ ERROR at least one abi must be provided
|
||||||
asm!("", clobber_abi(foo));
|
asm!("", clobber_abi(foo));
|
||||||
|
@ -46,6 +49,25 @@ fn main() {
|
||||||
//~^ ERROR expected one of `)` or `,`, found `foo`
|
//~^ ERROR expected one of `)` or `,`, found `foo`
|
||||||
asm!("", clobber_abi("C", foo));
|
asm!("", clobber_abi("C", foo));
|
||||||
//~^ ERROR expected string literal
|
//~^ ERROR expected string literal
|
||||||
|
asm!("", clobber_abi(1));
|
||||||
|
//~^ ERROR expected string literal
|
||||||
|
asm!("", clobber_abi(()));
|
||||||
|
//~^ ERROR expected string literal
|
||||||
|
asm!("", clobber_abi(uwu));
|
||||||
|
//~^ ERROR expected string literal
|
||||||
|
asm!("", clobber_abi({}));
|
||||||
|
//~^ ERROR expected string literal
|
||||||
|
asm!("", clobber_abi(loop {}));
|
||||||
|
//~^ ERROR expected string literal
|
||||||
|
asm!("", clobber_abi(if));
|
||||||
|
//~^ ERROR expected string literal
|
||||||
|
asm!("", clobber_abi(do));
|
||||||
|
//~^ ERROR expected string literal
|
||||||
|
asm!("", clobber_abi(<));
|
||||||
|
//~^ ERROR expected string literal
|
||||||
|
asm!("", clobber_abi(.));
|
||||||
|
//~^ ERROR expected string literal
|
||||||
|
|
||||||
asm!("{}", clobber_abi("C"), const foo);
|
asm!("{}", clobber_abi("C"), const foo);
|
||||||
//~^ ERROR attempt to use a non-constant value in a constant
|
//~^ ERROR attempt to use a non-constant value in a constant
|
||||||
asm!("", options(), clobber_abi("C"));
|
asm!("", options(), clobber_abi("C"));
|
||||||
|
@ -56,15 +78,7 @@ fn main() {
|
||||||
//~^^ ERROR argument never used
|
//~^^ ERROR argument never used
|
||||||
//~^^^ ERROR attempt to use a non-constant value in a constant
|
//~^^^ ERROR attempt to use a non-constant value in a constant
|
||||||
//~^^^^ ERROR attempt to use a non-constant value in a constant
|
//~^^^^ ERROR attempt to use a non-constant value in a constant
|
||||||
asm!("", a = in("eax") foo);
|
|
||||||
//~^ ERROR explicit register arguments cannot have names
|
|
||||||
asm!("{a}", in("eax") foo, a = const bar);
|
|
||||||
//~^ ERROR attempt to use a non-constant value in a constant
|
|
||||||
asm!("{a}", in("eax") foo, a = const bar);
|
|
||||||
//~^ ERROR attempt to use a non-constant value in a constant
|
|
||||||
asm!("{1}", in("eax") foo, const bar);
|
|
||||||
//~^ ERROR positional arguments cannot follow named arguments or explicit register arguments
|
|
||||||
//~^^ ERROR attempt to use a non-constant value in a constant
|
|
||||||
asm!("", options(), "");
|
asm!("", options(), "");
|
||||||
//~^ ERROR expected one of
|
//~^ ERROR expected one of
|
||||||
asm!("{}", in(reg) foo, "{}", out(reg) foo);
|
asm!("{}", in(reg) foo, "{}", out(reg) foo);
|
|
@ -83,31 +83,85 @@ LL | asm!("", options(nomem, foo));
|
||||||
| ^^^ expected one of 10 possible tokens
|
| ^^^ expected one of 10 possible tokens
|
||||||
|
|
||||||
error: at least one abi must be provided as an argument to `clobber_abi`
|
error: at least one abi must be provided as an argument to `clobber_abi`
|
||||||
--> $DIR/parse-error.rs:41:30
|
--> $DIR/parse-error.rs:44:30
|
||||||
|
|
|
|
||||||
LL | asm!("", clobber_abi());
|
LL | asm!("", clobber_abi());
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
error: expected string literal
|
error: expected string literal
|
||||||
--> $DIR/parse-error.rs:43:30
|
--> $DIR/parse-error.rs:46:30
|
||||||
|
|
|
|
||||||
LL | asm!("", clobber_abi(foo));
|
LL | asm!("", clobber_abi(foo));
|
||||||
| ^^^ not a string literal
|
| ^^^ not a string literal
|
||||||
|
|
||||||
error: expected one of `)` or `,`, found `foo`
|
error: expected one of `)` or `,`, found `foo`
|
||||||
--> $DIR/parse-error.rs:45:34
|
--> $DIR/parse-error.rs:48:34
|
||||||
|
|
|
|
||||||
LL | asm!("", clobber_abi("C" foo));
|
LL | asm!("", clobber_abi("C" foo));
|
||||||
| ^^^ expected one of `)` or `,`
|
| ^^^ expected one of `)` or `,`
|
||||||
|
|
||||||
error: expected string literal
|
error: expected string literal
|
||||||
--> $DIR/parse-error.rs:47:35
|
--> $DIR/parse-error.rs:50:35
|
||||||
|
|
|
|
||||||
LL | asm!("", clobber_abi("C", foo));
|
LL | asm!("", clobber_abi("C", foo));
|
||||||
| ^^^ not a string literal
|
| ^^^ not a string literal
|
||||||
|
|
||||||
|
error: expected string literal
|
||||||
|
--> $DIR/parse-error.rs:52:30
|
||||||
|
|
|
||||||
|
LL | asm!("", clobber_abi(1));
|
||||||
|
| ^ not a string literal
|
||||||
|
|
||||||
|
error: expected string literal
|
||||||
|
--> $DIR/parse-error.rs:54:30
|
||||||
|
|
|
||||||
|
LL | asm!("", clobber_abi(()));
|
||||||
|
| ^ not a string literal
|
||||||
|
|
||||||
|
error: expected string literal
|
||||||
|
--> $DIR/parse-error.rs:56:30
|
||||||
|
|
|
||||||
|
LL | asm!("", clobber_abi(uwu));
|
||||||
|
| ^^^ not a string literal
|
||||||
|
|
||||||
|
error: expected string literal
|
||||||
|
--> $DIR/parse-error.rs:58:30
|
||||||
|
|
|
||||||
|
LL | asm!("", clobber_abi({}));
|
||||||
|
| ^ not a string literal
|
||||||
|
|
||||||
|
error: expected string literal
|
||||||
|
--> $DIR/parse-error.rs:60:30
|
||||||
|
|
|
||||||
|
LL | asm!("", clobber_abi(loop {}));
|
||||||
|
| ^^^^ not a string literal
|
||||||
|
|
||||||
|
error: expected string literal
|
||||||
|
--> $DIR/parse-error.rs:62:30
|
||||||
|
|
|
||||||
|
LL | asm!("", clobber_abi(if));
|
||||||
|
| ^^ not a string literal
|
||||||
|
|
||||||
|
error: expected string literal
|
||||||
|
--> $DIR/parse-error.rs:64:30
|
||||||
|
|
|
||||||
|
LL | asm!("", clobber_abi(do));
|
||||||
|
| ^^ not a string literal
|
||||||
|
|
||||||
|
error: expected string literal
|
||||||
|
--> $DIR/parse-error.rs:66:30
|
||||||
|
|
|
||||||
|
LL | asm!("", clobber_abi(<));
|
||||||
|
| ^ not a string literal
|
||||||
|
|
||||||
|
error: expected string literal
|
||||||
|
--> $DIR/parse-error.rs:68:30
|
||||||
|
|
|
||||||
|
LL | asm!("", clobber_abi(.));
|
||||||
|
| ^ not a string literal
|
||||||
|
|
||||||
error: duplicate argument named `a`
|
error: duplicate argument named `a`
|
||||||
--> $DIR/parse-error.rs:54:36
|
--> $DIR/parse-error.rs:76:36
|
||||||
|
|
|
|
||||||
LL | asm!("{a}", a = const foo, a = const bar);
|
LL | asm!("{a}", a = const foo, a = const bar);
|
||||||
| ------------- ^^^^^^^^^^^^^ duplicate argument
|
| ------------- ^^^^^^^^^^^^^ duplicate argument
|
||||||
|
@ -115,41 +169,27 @@ LL | asm!("{a}", a = const foo, a = const bar);
|
||||||
| previously here
|
| previously here
|
||||||
|
|
||||||
error: argument never used
|
error: argument never used
|
||||||
--> $DIR/parse-error.rs:54:36
|
--> $DIR/parse-error.rs:76:36
|
||||||
|
|
|
|
||||||
LL | asm!("{a}", a = const foo, a = const bar);
|
LL | asm!("{a}", a = const foo, a = const bar);
|
||||||
| ^^^^^^^^^^^^^ argument never used
|
| ^^^^^^^^^^^^^ argument never used
|
||||||
|
|
|
|
||||||
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"`
|
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"`
|
||||||
|
|
||||||
error: explicit register arguments cannot have names
|
|
||||||
--> $DIR/parse-error.rs:59:18
|
|
||||||
|
|
|
||||||
LL | asm!("", a = in("eax") foo);
|
|
||||||
| ^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: positional arguments cannot follow named arguments or explicit register arguments
|
|
||||||
--> $DIR/parse-error.rs:65:36
|
|
||||||
|
|
|
||||||
LL | asm!("{1}", in("eax") foo, const bar);
|
|
||||||
| ------------- ^^^^^^^^^ positional argument
|
|
||||||
| |
|
|
||||||
| explicit register argument
|
|
||||||
|
|
||||||
error: expected one of `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `lateout`, `options`, `out`, or `sym`, found `""`
|
error: expected one of `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `lateout`, `options`, `out`, or `sym`, found `""`
|
||||||
--> $DIR/parse-error.rs:68:29
|
--> $DIR/parse-error.rs:82:29
|
||||||
|
|
|
|
||||||
LL | asm!("", options(), "");
|
LL | asm!("", options(), "");
|
||||||
| ^^ expected one of 9 possible tokens
|
| ^^ expected one of 9 possible tokens
|
||||||
|
|
||||||
error: expected one of `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `lateout`, `options`, `out`, or `sym`, found `"{}"`
|
error: expected one of `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `lateout`, `options`, `out`, or `sym`, found `"{}"`
|
||||||
--> $DIR/parse-error.rs:70:33
|
--> $DIR/parse-error.rs:84:33
|
||||||
|
|
|
|
||||||
LL | asm!("{}", in(reg) foo, "{}", out(reg) foo);
|
LL | asm!("{}", in(reg) foo, "{}", out(reg) foo);
|
||||||
| ^^^^ expected one of 9 possible tokens
|
| ^^^^ expected one of 9 possible tokens
|
||||||
|
|
||||||
error: asm template must be a string literal
|
error: asm template must be a string literal
|
||||||
--> $DIR/parse-error.rs:72:14
|
--> $DIR/parse-error.rs:86:14
|
||||||
|
|
|
|
||||||
LL | asm!(format!("{{{}}}", 0), in(reg) foo);
|
LL | asm!(format!("{{{}}}", 0), in(reg) foo);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -157,7 +197,7 @@ LL | asm!(format!("{{{}}}", 0), in(reg) foo);
|
||||||
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: asm template must be a string literal
|
error: asm template must be a string literal
|
||||||
--> $DIR/parse-error.rs:74:21
|
--> $DIR/parse-error.rs:88:21
|
||||||
|
|
|
|
||||||
LL | asm!("{1}", format!("{{{}}}", 0), in(reg) foo, out(reg) bar);
|
LL | asm!("{1}", format!("{{{}}}", 0), in(reg) foo, out(reg) bar);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -165,121 +205,121 @@ LL | asm!("{1}", format!("{{{}}}", 0), in(reg) foo, out(reg) bar);
|
||||||
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: _ cannot be used for input operands
|
error: _ cannot be used for input operands
|
||||||
--> $DIR/parse-error.rs:76:28
|
--> $DIR/parse-error.rs:90:28
|
||||||
|
|
|
|
||||||
LL | asm!("{}", in(reg) _);
|
LL | asm!("{}", in(reg) _);
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
error: _ cannot be used for input operands
|
error: _ cannot be used for input operands
|
||||||
--> $DIR/parse-error.rs:78:31
|
--> $DIR/parse-error.rs:92:31
|
||||||
|
|
|
|
||||||
LL | asm!("{}", inout(reg) _);
|
LL | asm!("{}", inout(reg) _);
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
error: _ cannot be used for input operands
|
error: _ cannot be used for input operands
|
||||||
--> $DIR/parse-error.rs:80:35
|
--> $DIR/parse-error.rs:94:35
|
||||||
|
|
|
|
||||||
LL | asm!("{}", inlateout(reg) _);
|
LL | asm!("{}", inlateout(reg) _);
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
error: requires at least a template string argument
|
error: requires at least a template string argument
|
||||||
--> $DIR/parse-error.rs:87:1
|
--> $DIR/parse-error.rs:101:1
|
||||||
|
|
|
|
||||||
LL | global_asm!();
|
LL | global_asm!();
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: asm template must be a string literal
|
error: asm template must be a string literal
|
||||||
--> $DIR/parse-error.rs:89:13
|
--> $DIR/parse-error.rs:103:13
|
||||||
|
|
|
|
||||||
LL | global_asm!(FOO);
|
LL | global_asm!(FOO);
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: expected token: `,`
|
error: expected token: `,`
|
||||||
--> $DIR/parse-error.rs:91:18
|
--> $DIR/parse-error.rs:105:18
|
||||||
|
|
|
|
||||||
LL | global_asm!("{}" FOO);
|
LL | global_asm!("{}" FOO);
|
||||||
| ^^^ expected `,`
|
| ^^^ expected `,`
|
||||||
|
|
||||||
error: expected operand, options, or additional template string
|
error: expected operand, options, or additional template string
|
||||||
--> $DIR/parse-error.rs:93:19
|
--> $DIR/parse-error.rs:107:19
|
||||||
|
|
|
|
||||||
LL | global_asm!("{}", FOO);
|
LL | global_asm!("{}", FOO);
|
||||||
| ^^^ expected operand, options, or additional template string
|
| ^^^ expected operand, options, or additional template string
|
||||||
|
|
||||||
error: expected expression, found end of macro arguments
|
error: expected expression, found end of macro arguments
|
||||||
--> $DIR/parse-error.rs:95:24
|
--> $DIR/parse-error.rs:109:24
|
||||||
|
|
|
|
||||||
LL | global_asm!("{}", const);
|
LL | global_asm!("{}", const);
|
||||||
| ^ expected expression
|
| ^ expected expression
|
||||||
|
|
||||||
error: expected one of `,`, `.`, `?`, or an operator, found `FOO`
|
error: expected one of `,`, `.`, `?`, or an operator, found `FOO`
|
||||||
--> $DIR/parse-error.rs:97:30
|
--> $DIR/parse-error.rs:111:30
|
||||||
|
|
|
|
||||||
LL | global_asm!("{}", const(reg) FOO);
|
LL | global_asm!("{}", const(reg) FOO);
|
||||||
| ^^^ expected one of `,`, `.`, `?`, or an operator
|
| ^^^ expected one of `,`, `.`, `?`, or an operator
|
||||||
|
|
||||||
error: expected one of `)`, `att_syntax`, or `raw`, found `FOO`
|
error: expected one of `)`, `att_syntax`, or `raw`, found `FOO`
|
||||||
--> $DIR/parse-error.rs:99:25
|
--> $DIR/parse-error.rs:113:25
|
||||||
|
|
|
|
||||||
LL | global_asm!("", options(FOO));
|
LL | global_asm!("", options(FOO));
|
||||||
| ^^^ expected one of `)`, `att_syntax`, or `raw`
|
| ^^^ expected one of `)`, `att_syntax`, or `raw`
|
||||||
|
|
||||||
error: expected one of `)`, `att_syntax`, or `raw`, found `nomem`
|
error: expected one of `)`, `att_syntax`, or `raw`, found `nomem`
|
||||||
--> $DIR/parse-error.rs:101:25
|
--> $DIR/parse-error.rs:115:25
|
||||||
|
|
|
|
||||||
LL | global_asm!("", options(nomem FOO));
|
LL | global_asm!("", options(nomem FOO));
|
||||||
| ^^^^^ expected one of `)`, `att_syntax`, or `raw`
|
| ^^^^^ expected one of `)`, `att_syntax`, or `raw`
|
||||||
|
|
||||||
error: expected one of `)`, `att_syntax`, or `raw`, found `nomem`
|
error: expected one of `)`, `att_syntax`, or `raw`, found `nomem`
|
||||||
--> $DIR/parse-error.rs:103:25
|
--> $DIR/parse-error.rs:117:25
|
||||||
|
|
|
|
||||||
LL | global_asm!("", options(nomem, FOO));
|
LL | global_asm!("", options(nomem, FOO));
|
||||||
| ^^^^^ expected one of `)`, `att_syntax`, or `raw`
|
| ^^^^^ expected one of `)`, `att_syntax`, or `raw`
|
||||||
|
|
||||||
error: expected string literal
|
error: expected string literal
|
||||||
--> $DIR/parse-error.rs:106:29
|
--> $DIR/parse-error.rs:120:29
|
||||||
|
|
|
|
||||||
LL | global_asm!("", clobber_abi(FOO));
|
LL | global_asm!("", clobber_abi(FOO));
|
||||||
| ^^^ not a string literal
|
| ^^^ not a string literal
|
||||||
|
|
||||||
error: expected one of `)` or `,`, found `FOO`
|
error: expected one of `)` or `,`, found `FOO`
|
||||||
--> $DIR/parse-error.rs:108:33
|
--> $DIR/parse-error.rs:122:33
|
||||||
|
|
|
|
||||||
LL | global_asm!("", clobber_abi("C" FOO));
|
LL | global_asm!("", clobber_abi("C" FOO));
|
||||||
| ^^^ expected one of `)` or `,`
|
| ^^^ expected one of `)` or `,`
|
||||||
|
|
||||||
error: expected string literal
|
error: expected string literal
|
||||||
--> $DIR/parse-error.rs:110:34
|
--> $DIR/parse-error.rs:124:34
|
||||||
|
|
|
|
||||||
LL | global_asm!("", clobber_abi("C", FOO));
|
LL | global_asm!("", clobber_abi("C", FOO));
|
||||||
| ^^^ not a string literal
|
| ^^^ not a string literal
|
||||||
|
|
||||||
error: `clobber_abi` cannot be used with `global_asm!`
|
error: `clobber_abi` cannot be used with `global_asm!`
|
||||||
--> $DIR/parse-error.rs:112:19
|
--> $DIR/parse-error.rs:126:19
|
||||||
|
|
|
|
||||||
LL | global_asm!("{}", clobber_abi("C"), const FOO);
|
LL | global_asm!("{}", clobber_abi("C"), const FOO);
|
||||||
| ^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: `clobber_abi` cannot be used with `global_asm!`
|
error: `clobber_abi` cannot be used with `global_asm!`
|
||||||
--> $DIR/parse-error.rs:114:28
|
--> $DIR/parse-error.rs:128:28
|
||||||
|
|
|
|
||||||
LL | global_asm!("", options(), clobber_abi("C"));
|
LL | global_asm!("", options(), clobber_abi("C"));
|
||||||
| ^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: `clobber_abi` cannot be used with `global_asm!`
|
error: `clobber_abi` cannot be used with `global_asm!`
|
||||||
--> $DIR/parse-error.rs:116:30
|
--> $DIR/parse-error.rs:130:30
|
||||||
|
|
|
|
||||||
LL | global_asm!("{}", options(), clobber_abi("C"), const FOO);
|
LL | global_asm!("{}", options(), clobber_abi("C"), const FOO);
|
||||||
| ^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: `clobber_abi` cannot be used with `global_asm!`
|
error: `clobber_abi` cannot be used with `global_asm!`
|
||||||
--> $DIR/parse-error.rs:118:17
|
--> $DIR/parse-error.rs:132:17
|
||||||
|
|
|
|
||||||
LL | global_asm!("", clobber_abi("C"), clobber_abi("C"));
|
LL | global_asm!("", clobber_abi("C"), clobber_abi("C"));
|
||||||
| ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: duplicate argument named `a`
|
error: duplicate argument named `a`
|
||||||
--> $DIR/parse-error.rs:120:35
|
--> $DIR/parse-error.rs:134:35
|
||||||
|
|
|
|
||||||
LL | global_asm!("{a}", a = const FOO, a = const BAR);
|
LL | global_asm!("{a}", a = const FOO, a = const BAR);
|
||||||
| ------------- ^^^^^^^^^^^^^ duplicate argument
|
| ------------- ^^^^^^^^^^^^^ duplicate argument
|
||||||
|
@ -287,7 +327,7 @@ LL | global_asm!("{a}", a = const FOO, a = const BAR);
|
||||||
| previously here
|
| previously here
|
||||||
|
|
||||||
error: argument never used
|
error: argument never used
|
||||||
--> $DIR/parse-error.rs:120:35
|
--> $DIR/parse-error.rs:134:35
|
||||||
|
|
|
|
||||||
LL | global_asm!("{a}", a = const FOO, a = const BAR);
|
LL | global_asm!("{a}", a = const FOO, a = const BAR);
|
||||||
| ^^^^^^^^^^^^^ argument never used
|
| ^^^^^^^^^^^^^ argument never used
|
||||||
|
@ -295,19 +335,19 @@ LL | global_asm!("{a}", a = const FOO, a = const BAR);
|
||||||
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"`
|
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"`
|
||||||
|
|
||||||
error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `""`
|
error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `""`
|
||||||
--> $DIR/parse-error.rs:123:28
|
--> $DIR/parse-error.rs:137:28
|
||||||
|
|
|
|
||||||
LL | global_asm!("", options(), "");
|
LL | global_asm!("", options(), "");
|
||||||
| ^^ expected one of `clobber_abi`, `const`, `options`, or `sym`
|
| ^^ expected one of `clobber_abi`, `const`, `options`, or `sym`
|
||||||
|
|
||||||
error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `"{}"`
|
error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `"{}"`
|
||||||
--> $DIR/parse-error.rs:125:30
|
--> $DIR/parse-error.rs:139:30
|
||||||
|
|
|
|
||||||
LL | global_asm!("{}", const FOO, "{}", const FOO);
|
LL | global_asm!("{}", const FOO, "{}", const FOO);
|
||||||
| ^^^^ expected one of `clobber_abi`, `const`, `options`, or `sym`
|
| ^^^^ expected one of `clobber_abi`, `const`, `options`, or `sym`
|
||||||
|
|
||||||
error: asm template must be a string literal
|
error: asm template must be a string literal
|
||||||
--> $DIR/parse-error.rs:127:13
|
--> $DIR/parse-error.rs:141:13
|
||||||
|
|
|
|
||||||
LL | global_asm!(format!("{{{}}}", 0), const FOO);
|
LL | global_asm!(format!("{{{}}}", 0), const FOO);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -315,7 +355,7 @@ LL | global_asm!(format!("{{{}}}", 0), const FOO);
|
||||||
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: asm template must be a string literal
|
error: asm template must be a string literal
|
||||||
--> $DIR/parse-error.rs:129:20
|
--> $DIR/parse-error.rs:143:20
|
||||||
|
|
|
|
||||||
LL | global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR);
|
LL | global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -332,7 +372,7 @@ LL | asm!("{}", options(), const foo);
|
||||||
| ^^^ non-constant value
|
| ^^^ non-constant value
|
||||||
|
|
||||||
error[E0435]: attempt to use a non-constant value in a constant
|
error[E0435]: attempt to use a non-constant value in a constant
|
||||||
--> $DIR/parse-error.rs:49:44
|
--> $DIR/parse-error.rs:71:44
|
||||||
|
|
|
|
||||||
LL | let mut foo = 0;
|
LL | let mut foo = 0;
|
||||||
| ----------- help: consider using `const` instead of `let`: `const foo`
|
| ----------- help: consider using `const` instead of `let`: `const foo`
|
||||||
|
@ -341,7 +381,7 @@ LL | asm!("{}", clobber_abi("C"), const foo);
|
||||||
| ^^^ non-constant value
|
| ^^^ non-constant value
|
||||||
|
|
||||||
error[E0435]: attempt to use a non-constant value in a constant
|
error[E0435]: attempt to use a non-constant value in a constant
|
||||||
--> $DIR/parse-error.rs:52:55
|
--> $DIR/parse-error.rs:74:55
|
||||||
|
|
|
|
||||||
LL | let mut foo = 0;
|
LL | let mut foo = 0;
|
||||||
| ----------- help: consider using `const` instead of `let`: `const foo`
|
| ----------- help: consider using `const` instead of `let`: `const foo`
|
||||||
|
@ -350,7 +390,7 @@ LL | asm!("{}", options(), clobber_abi("C"), const foo);
|
||||||
| ^^^ non-constant value
|
| ^^^ non-constant value
|
||||||
|
|
||||||
error[E0435]: attempt to use a non-constant value in a constant
|
error[E0435]: attempt to use a non-constant value in a constant
|
||||||
--> $DIR/parse-error.rs:54:31
|
--> $DIR/parse-error.rs:76:31
|
||||||
|
|
|
|
||||||
LL | let mut foo = 0;
|
LL | let mut foo = 0;
|
||||||
| ----------- help: consider using `const` instead of `let`: `const foo`
|
| ----------- help: consider using `const` instead of `let`: `const foo`
|
||||||
|
@ -359,7 +399,7 @@ LL | asm!("{a}", a = const foo, a = const bar);
|
||||||
| ^^^ non-constant value
|
| ^^^ non-constant value
|
||||||
|
|
||||||
error[E0435]: attempt to use a non-constant value in a constant
|
error[E0435]: attempt to use a non-constant value in a constant
|
||||||
--> $DIR/parse-error.rs:54:46
|
--> $DIR/parse-error.rs:76:46
|
||||||
|
|
|
|
||||||
LL | let mut bar = 0;
|
LL | let mut bar = 0;
|
||||||
| ----------- help: consider using `const` instead of `let`: `const bar`
|
| ----------- help: consider using `const` instead of `let`: `const bar`
|
||||||
|
@ -367,33 +407,6 @@ LL | let mut bar = 0;
|
||||||
LL | asm!("{a}", a = const foo, a = const bar);
|
LL | asm!("{a}", a = const foo, a = const bar);
|
||||||
| ^^^ non-constant value
|
| ^^^ non-constant value
|
||||||
|
|
||||||
error[E0435]: attempt to use a non-constant value in a constant
|
error: aborting due to 63 previous errors
|
||||||
--> $DIR/parse-error.rs:61:46
|
|
||||||
|
|
|
||||||
LL | let mut bar = 0;
|
|
||||||
| ----------- help: consider using `const` instead of `let`: `const bar`
|
|
||||||
...
|
|
||||||
LL | asm!("{a}", in("eax") foo, a = const bar);
|
|
||||||
| ^^^ non-constant value
|
|
||||||
|
|
||||||
error[E0435]: attempt to use a non-constant value in a constant
|
|
||||||
--> $DIR/parse-error.rs:63:46
|
|
||||||
|
|
|
||||||
LL | let mut bar = 0;
|
|
||||||
| ----------- help: consider using `const` instead of `let`: `const bar`
|
|
||||||
...
|
|
||||||
LL | asm!("{a}", in("eax") foo, a = const bar);
|
|
||||||
| ^^^ non-constant value
|
|
||||||
|
|
||||||
error[E0435]: attempt to use a non-constant value in a constant
|
|
||||||
--> $DIR/parse-error.rs:65:42
|
|
||||||
|
|
|
||||||
LL | let mut bar = 0;
|
|
||||||
| ----------- help: consider using `const` instead of `let`: `const bar`
|
|
||||||
...
|
|
||||||
LL | asm!("{1}", in("eax") foo, const bar);
|
|
||||||
| ^^^ non-constant value
|
|
||||||
|
|
||||||
error: aborting due to 59 previous errors
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0435`.
|
For more information about this error, try `rustc --explain E0435`.
|
21
tests/ui/asm/x86_64/x86_64_parse_error.rs
Normal file
21
tests/ui/asm/x86_64/x86_64_parse_error.rs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
// only-x86_64
|
||||||
|
|
||||||
|
#![feature(asm_const)]
|
||||||
|
|
||||||
|
use std::arch::asm;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut foo = 0;
|
||||||
|
let mut bar = 0;
|
||||||
|
unsafe {
|
||||||
|
asm!("", a = in("eax") foo);
|
||||||
|
//~^ ERROR explicit register arguments cannot have names
|
||||||
|
asm!("{a}", in("eax") foo, a = const bar);
|
||||||
|
//~^ ERROR attempt to use a non-constant value in a constant
|
||||||
|
asm!("{a}", in("eax") foo, a = const bar);
|
||||||
|
//~^ ERROR attempt to use a non-constant value in a constant
|
||||||
|
asm!("{1}", in("eax") foo, const bar);
|
||||||
|
//~^ ERROR positional arguments cannot follow named arguments or explicit register arguments
|
||||||
|
//~^^ ERROR attempt to use a non-constant value in a constant
|
||||||
|
}
|
||||||
|
}
|
44
tests/ui/asm/x86_64/x86_64_parse_error.stderr
Normal file
44
tests/ui/asm/x86_64/x86_64_parse_error.stderr
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
error: explicit register arguments cannot have names
|
||||||
|
--> $DIR/x86_64_parse_error.rs:11:18
|
||||||
|
|
|
||||||
|
LL | asm!("", a = in("eax") foo);
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: positional arguments cannot follow named arguments or explicit register arguments
|
||||||
|
--> $DIR/x86_64_parse_error.rs:17:36
|
||||||
|
|
|
||||||
|
LL | asm!("{1}", in("eax") foo, const bar);
|
||||||
|
| ------------- ^^^^^^^^^ positional argument
|
||||||
|
| |
|
||||||
|
| explicit register argument
|
||||||
|
|
||||||
|
error[E0435]: attempt to use a non-constant value in a constant
|
||||||
|
--> $DIR/x86_64_parse_error.rs:13:46
|
||||||
|
|
|
||||||
|
LL | let mut bar = 0;
|
||||||
|
| ----------- help: consider using `const` instead of `let`: `const bar`
|
||||||
|
...
|
||||||
|
LL | asm!("{a}", in("eax") foo, a = const bar);
|
||||||
|
| ^^^ non-constant value
|
||||||
|
|
||||||
|
error[E0435]: attempt to use a non-constant value in a constant
|
||||||
|
--> $DIR/x86_64_parse_error.rs:15:46
|
||||||
|
|
|
||||||
|
LL | let mut bar = 0;
|
||||||
|
| ----------- help: consider using `const` instead of `let`: `const bar`
|
||||||
|
...
|
||||||
|
LL | asm!("{a}", in("eax") foo, a = const bar);
|
||||||
|
| ^^^ non-constant value
|
||||||
|
|
||||||
|
error[E0435]: attempt to use a non-constant value in a constant
|
||||||
|
--> $DIR/x86_64_parse_error.rs:17:42
|
||||||
|
|
|
||||||
|
LL | let mut bar = 0;
|
||||||
|
| ----------- help: consider using `const` instead of `let`: `const bar`
|
||||||
|
...
|
||||||
|
LL | asm!("{1}", in("eax") foo, const bar);
|
||||||
|
| ^^^ non-constant value
|
||||||
|
|
||||||
|
error: aborting due to 5 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0435`.
|
Loading…
Add table
Reference in a new issue