Properly reject the may_unwind option in global_asm!

This was accidentally accepted even though it had no effect in
`global_asm!`. The option only makes sense for `asm!` which runs within
a function.
This commit is contained in:
Amanieu d'Antras 2022-08-02 05:25:45 +01:00
parent 9d5cd21a5d
commit 96c955e66b
5 changed files with 38 additions and 38 deletions

View file

@ -410,12 +410,12 @@ fn parse_options<'a>(
try_set_option(p, args, sym::noreturn, ast::InlineAsmOptions::NORETURN); try_set_option(p, args, sym::noreturn, ast::InlineAsmOptions::NORETURN);
} else if !is_global_asm && p.eat_keyword(sym::nostack) { } else if !is_global_asm && p.eat_keyword(sym::nostack) {
try_set_option(p, args, sym::nostack, ast::InlineAsmOptions::NOSTACK); try_set_option(p, args, sym::nostack, ast::InlineAsmOptions::NOSTACK);
} else if !is_global_asm && p.eat_keyword(sym::may_unwind) {
try_set_option(p, args, kw::Raw, ast::InlineAsmOptions::MAY_UNWIND);
} else if p.eat_keyword(sym::att_syntax) { } else if p.eat_keyword(sym::att_syntax) {
try_set_option(p, args, sym::att_syntax, ast::InlineAsmOptions::ATT_SYNTAX); try_set_option(p, args, sym::att_syntax, ast::InlineAsmOptions::ATT_SYNTAX);
} else if p.eat_keyword(kw::Raw) { } else if p.eat_keyword(kw::Raw) {
try_set_option(p, args, kw::Raw, ast::InlineAsmOptions::RAW); try_set_option(p, args, kw::Raw, ast::InlineAsmOptions::RAW);
} else if p.eat_keyword(sym::may_unwind) {
try_set_option(p, args, kw::Raw, ast::InlineAsmOptions::MAY_UNWIND);
} else { } else {
return p.unexpected(); return p.unexpected();
} }

View file

@ -36,41 +36,41 @@ LL | asm!("{}", out(reg) foo, clobber_abi("C"));
| | | |
| generic outputs | generic outputs
error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `nomem` error: expected one of `)`, `att_syntax`, or `raw`, found `nomem`
--> $DIR/bad-options.rs:28:25 --> $DIR/bad-options.rs:28:25
| |
LL | global_asm!("", options(nomem)); LL | global_asm!("", options(nomem));
| ^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` | ^^^^^ expected one of `)`, `att_syntax`, or `raw`
error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `readonly` error: expected one of `)`, `att_syntax`, or `raw`, found `readonly`
--> $DIR/bad-options.rs:30:25 --> $DIR/bad-options.rs:30:25
| |
LL | global_asm!("", options(readonly)); LL | global_asm!("", options(readonly));
| ^^^^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` | ^^^^^^^^ expected one of `)`, `att_syntax`, or `raw`
error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `noreturn` error: expected one of `)`, `att_syntax`, or `raw`, found `noreturn`
--> $DIR/bad-options.rs:32:25 --> $DIR/bad-options.rs:32:25
| |
LL | global_asm!("", options(noreturn)); LL | global_asm!("", options(noreturn));
| ^^^^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` | ^^^^^^^^ expected one of `)`, `att_syntax`, or `raw`
error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `pure` error: expected one of `)`, `att_syntax`, or `raw`, found `pure`
--> $DIR/bad-options.rs:34:25 --> $DIR/bad-options.rs:34:25
| |
LL | global_asm!("", options(pure)); LL | global_asm!("", options(pure));
| ^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` | ^^^^ expected one of `)`, `att_syntax`, or `raw`
error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `nostack` error: expected one of `)`, `att_syntax`, or `raw`, found `nostack`
--> $DIR/bad-options.rs:36:25 --> $DIR/bad-options.rs:36:25
| |
LL | global_asm!("", options(nostack)); LL | global_asm!("", options(nostack));
| ^^^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` | ^^^^^^^ expected one of `)`, `att_syntax`, or `raw`
error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `preserves_flags` error: expected one of `)`, `att_syntax`, or `raw`, found `preserves_flags`
--> $DIR/bad-options.rs:38:25 --> $DIR/bad-options.rs:38:25
| |
LL | global_asm!("", options(preserves_flags)); LL | global_asm!("", options(preserves_flags));
| ^^^^^^^^^^^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` | ^^^^^^^^^^^^^^^ expected one of `)`, `att_syntax`, or `raw`
error: invalid ABI for `clobber_abi` error: invalid ABI for `clobber_abi`
--> $DIR/bad-options.rs:20:18 --> $DIR/bad-options.rs:20:18

View file

@ -260,23 +260,23 @@ error: expected one of `,`, `.`, `?`, or an operator, found `FOO`
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`, `may_unwind`, or `raw`, found `FOO` error: expected one of `)`, `att_syntax`, or `raw`, found `FOO`
--> $DIR/parse-error.rs:102:25 --> $DIR/parse-error.rs:102:25
| |
LL | global_asm!("", options(FOO)); LL | global_asm!("", options(FOO));
| ^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` | ^^^ expected one of `)`, `att_syntax`, or `raw`
error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `nomem` error: expected one of `)`, `att_syntax`, or `raw`, found `nomem`
--> $DIR/parse-error.rs:104:25 --> $DIR/parse-error.rs:104:25
| |
LL | global_asm!("", options(nomem FOO)); LL | global_asm!("", options(nomem FOO));
| ^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` | ^^^^^ expected one of `)`, `att_syntax`, or `raw`
error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `nomem` error: expected one of `)`, `att_syntax`, or `raw`, found `nomem`
--> $DIR/parse-error.rs:106:25 --> $DIR/parse-error.rs:106:25
| |
LL | global_asm!("", options(nomem, FOO)); LL | global_asm!("", options(nomem, FOO));
| ^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` | ^^^^^ expected one of `)`, `att_syntax`, or `raw`
error: arguments are not allowed after options error: arguments are not allowed after options
--> $DIR/parse-error.rs:108:30 --> $DIR/parse-error.rs:108:30

View file

@ -45,41 +45,41 @@ LL | asm!("{}", out(reg) foo, clobber_abi("C"), clobber_abi("C"));
| | clobber_abi | | clobber_abi
| generic outputs | generic outputs
error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `nomem` error: expected one of `)`, `att_syntax`, or `raw`, found `nomem`
--> $DIR/bad-options.rs:31:25 --> $DIR/bad-options.rs:31:25
| |
LL | global_asm!("", options(nomem)); LL | global_asm!("", options(nomem));
| ^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` | ^^^^^ expected one of `)`, `att_syntax`, or `raw`
error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `readonly` error: expected one of `)`, `att_syntax`, or `raw`, found `readonly`
--> $DIR/bad-options.rs:33:25 --> $DIR/bad-options.rs:33:25
| |
LL | global_asm!("", options(readonly)); LL | global_asm!("", options(readonly));
| ^^^^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` | ^^^^^^^^ expected one of `)`, `att_syntax`, or `raw`
error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `noreturn` error: expected one of `)`, `att_syntax`, or `raw`, found `noreturn`
--> $DIR/bad-options.rs:35:25 --> $DIR/bad-options.rs:35:25
| |
LL | global_asm!("", options(noreturn)); LL | global_asm!("", options(noreturn));
| ^^^^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` | ^^^^^^^^ expected one of `)`, `att_syntax`, or `raw`
error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `pure` error: expected one of `)`, `att_syntax`, or `raw`, found `pure`
--> $DIR/bad-options.rs:37:25 --> $DIR/bad-options.rs:37:25
| |
LL | global_asm!("", options(pure)); LL | global_asm!("", options(pure));
| ^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` | ^^^^ expected one of `)`, `att_syntax`, or `raw`
error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `nostack` error: expected one of `)`, `att_syntax`, or `raw`, found `nostack`
--> $DIR/bad-options.rs:39:25 --> $DIR/bad-options.rs:39:25
| |
LL | global_asm!("", options(nostack)); LL | global_asm!("", options(nostack));
| ^^^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` | ^^^^^^^ expected one of `)`, `att_syntax`, or `raw`
error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `preserves_flags` error: expected one of `)`, `att_syntax`, or `raw`, found `preserves_flags`
--> $DIR/bad-options.rs:41:25 --> $DIR/bad-options.rs:41:25
| |
LL | global_asm!("", options(preserves_flags)); LL | global_asm!("", options(preserves_flags));
| ^^^^^^^^^^^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` | ^^^^^^^^^^^^^^^ expected one of `)`, `att_syntax`, or `raw`
error: invalid ABI for `clobber_abi` error: invalid ABI for `clobber_abi`
--> $DIR/bad-options.rs:20:18 --> $DIR/bad-options.rs:20:18

View file

@ -266,23 +266,23 @@ error: expected one of `,`, `.`, `?`, or an operator, found `FOO`
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`, `may_unwind`, or `raw`, found `FOO` error: expected one of `)`, `att_syntax`, or `raw`, found `FOO`
--> $DIR/parse-error.rs:104:25 --> $DIR/parse-error.rs:104:25
| |
LL | global_asm!("", options(FOO)); LL | global_asm!("", options(FOO));
| ^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` | ^^^ expected one of `)`, `att_syntax`, or `raw`
error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `nomem` error: expected one of `)`, `att_syntax`, or `raw`, found `nomem`
--> $DIR/parse-error.rs:106:25 --> $DIR/parse-error.rs:106:25
| |
LL | global_asm!("", options(nomem FOO)); LL | global_asm!("", options(nomem FOO));
| ^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` | ^^^^^ expected one of `)`, `att_syntax`, or `raw`
error: expected one of `)`, `att_syntax`, `may_unwind`, or `raw`, found `nomem` error: expected one of `)`, `att_syntax`, or `raw`, found `nomem`
--> $DIR/parse-error.rs:108:25 --> $DIR/parse-error.rs:108:25
| |
LL | global_asm!("", options(nomem, FOO)); LL | global_asm!("", options(nomem, FOO));
| ^^^^^ expected one of `)`, `att_syntax`, `may_unwind`, or `raw` | ^^^^^ expected one of `)`, `att_syntax`, or `raw`
error: arguments are not allowed after options error: arguments are not allowed after options
--> $DIR/parse-error.rs:110:30 --> $DIR/parse-error.rs:110:30