diff options
| author | Folkert de Vries <folkert@folkertdev.nl> | 2024-08-23 16:38:20 +0200 |
|---|---|---|
| committer | Folkert de Vries <folkert@folkertdev.nl> | 2024-09-04 20:06:38 +0200 |
| commit | 49e3b9a2d2cf9bfbc5ada8e3d5dba8dee507dace (patch) | |
| tree | ab4e439aefe05d0d3444d6a99e618e8748ce8e97 /tests/ui/asm | |
| parent | f7679d050793304eff9ff2a46a824cc5495e6f93 (diff) | |
| download | rust-49e3b9a2d2cf9bfbc5ada8e3d5dba8dee507dace.tar.gz rust-49e3b9a2d2cf9bfbc5ada8e3d5dba8dee507dace.zip | |
fix ICE when `asm_const` and `const_refs_to_static` are combined
Diffstat (limited to 'tests/ui/asm')
| -rw-r--r-- | tests/ui/asm/const-refs-to-static.rs | 21 | ||||
| -rw-r--r-- | tests/ui/asm/const-refs-to-static.stderr | 22 |
2 files changed, 43 insertions, 0 deletions
diff --git a/tests/ui/asm/const-refs-to-static.rs b/tests/ui/asm/const-refs-to-static.rs new file mode 100644 index 00000000000..9fc010b5763 --- /dev/null +++ b/tests/ui/asm/const-refs-to-static.rs @@ -0,0 +1,21 @@ +//@ needs-asm-support +//@ ignore-nvptx64 +//@ ignore-spirv + +#![feature(const_refs_to_static)] + +use std::arch::{asm, global_asm}; +use std::ptr::addr_of; + +static FOO: u8 = 42; + +global_asm!("{}", const addr_of!(FOO)); +//~^ ERROR invalid type for `const` operand + +#[no_mangle] +fn inline() { + unsafe { asm!("{}", const addr_of!(FOO)) }; + //~^ ERROR invalid type for `const` operand +} + +fn main() {} diff --git a/tests/ui/asm/const-refs-to-static.stderr b/tests/ui/asm/const-refs-to-static.stderr new file mode 100644 index 00000000000..8fd69da0d1e --- /dev/null +++ b/tests/ui/asm/const-refs-to-static.stderr @@ -0,0 +1,22 @@ +error: invalid type for `const` operand + --> $DIR/const-refs-to-static.rs:12:19 + | +LL | global_asm!("{}", const addr_of!(FOO)); + | ^^^^^^------------- + | | + | is a `*const u8` + | + = help: `const` operands must be of an integer type + +error: invalid type for `const` operand + --> $DIR/const-refs-to-static.rs:17:25 + | +LL | unsafe { asm!("{}", const addr_of!(FOO)) }; + | ^^^^^^------------- + | | + | is a `*const u8` + | + = help: `const` operands must be of an integer type + +error: aborting due to 2 previous errors + |
