Auto merge of #77595 - petrochenkov:asmident, r=oli-obk
builtin_macros: Fix use of interpolated identifiers in `asm!` Fixes https://github.com/rust-lang/rust/issues/77584
This commit is contained in:
commit
a14bf4862d
5 changed files with 95 additions and 20 deletions
24
src/test/ui/asm/interpolated-idents.rs
Normal file
24
src/test/ui/asm/interpolated-idents.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// only-x86_64
|
||||
|
||||
#![feature(asm)]
|
||||
|
||||
macro_rules! m {
|
||||
($in:ident $out:ident $lateout:ident $inout:ident $inlateout:ident $const:ident $sym:ident
|
||||
$pure:ident $nomem:ident $readonly:ident $preserves_flags:ident
|
||||
$noreturn:ident $nostack:ident $att_syntax:ident $options:ident) => {
|
||||
unsafe {
|
||||
asm!("", $in(x) x, $out(x) x, $lateout(x) x, $inout(x) x, $inlateout(x) x,
|
||||
//~^ ERROR asm outputs are not allowed with the `noreturn` option
|
||||
const x, sym x,
|
||||
$options($pure, $nomem, $readonly, $preserves_flags, $noreturn, $nostack, $att_syntax));
|
||||
//~^ ERROR the `nomem` and `readonly` options are mutually exclusive
|
||||
//~| ERROR the `pure` and `noreturn` options are mutually exclusive
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
fn main() {
|
||||
m!(in out lateout inout inlateout const sym
|
||||
pure nomem readonly preserves_flags
|
||||
noreturn nostack att_syntax options);
|
||||
}
|
||||
51
src/test/ui/asm/interpolated-idents.stderr
Normal file
51
src/test/ui/asm/interpolated-idents.stderr
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
error: the `nomem` and `readonly` options are mutually exclusive
|
||||
--> $DIR/interpolated-idents.rs:13:13
|
||||
|
|
||||
LL | $options($pure, $nomem, $readonly, $preserves_flags, $noreturn, $nostack, $att_syntax));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | / m!(in out lateout inout inlateout const sym
|
||||
LL | | pure nomem readonly preserves_flags
|
||||
LL | | noreturn nostack att_syntax options);
|
||||
| |____________________________________________- in this macro invocation
|
||||
|
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: the `pure` and `noreturn` options are mutually exclusive
|
||||
--> $DIR/interpolated-idents.rs:13:13
|
||||
|
|
||||
LL | $options($pure, $nomem, $readonly, $preserves_flags, $noreturn, $nostack, $att_syntax));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | / m!(in out lateout inout inlateout const sym
|
||||
LL | | pure nomem readonly preserves_flags
|
||||
LL | | noreturn nostack att_syntax options);
|
||||
| |____________________________________________- in this macro invocation
|
||||
|
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: asm outputs are not allowed with the `noreturn` option
|
||||
--> $DIR/interpolated-idents.rs:10:32
|
||||
|
|
||||
LL | asm!("", $in(x) x, $out(x) x, $lateout(x) x, $inout(x) x, $inlateout(x) x,
|
||||
| ^^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | m!(in out lateout inout inlateout const sym
|
||||
| _____-
|
||||
| |_____|
|
||||
| |_____|
|
||||
| |_____|
|
||||
| |
|
||||
LL | | pure nomem readonly preserves_flags
|
||||
LL | | noreturn nostack att_syntax options);
|
||||
| | -
|
||||
| |____________________________________________|
|
||||
| |____________________________________________in this macro invocation
|
||||
| |____________________________________________in this macro invocation
|
||||
| |____________________________________________in this macro invocation
|
||||
| in this macro invocation
|
||||
|
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue