rust/tests/assembly/cstring-merging.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
769 B
Rust
Raw Normal View History

// MIPS assembler uses the label prefix `$anon.` for local anonymous variables
// other architectures (including ARM and x86-64) use the prefix `.Lanon.`
2025-03-25 12:57:42 +00:00
//@ only-linux
//@ assembly-output: emit-asm
//@ compile-flags: --crate-type=lib -Copt-level=3
//@ edition: 2024
2025-03-25 12:57:42 +00:00
use std::ffi::CStr;
// CHECK: .section .rodata.str1.{{[12]}},"aMS"
// CHECK: {{(\.L|\$)}}anon.{{.+}}:
2025-03-25 12:57:42 +00:00
// CHECK-NEXT: .asciz "foo"
#[unsafe(no_mangle)]
static CSTR: &[u8; 4] = b"foo\0";
// CHECK-NOT: .section
// CHECK: {{(\.L|\$)}}anon.{{.+}}:
2025-03-25 12:57:42 +00:00
// CHECK-NEXT: .asciz "bar"
#[unsafe(no_mangle)]
pub fn cstr() -> &'static CStr {
c"bar"
}
// CHECK-NOT: .section
// CHECK: {{(\.L|\$)}}anon.{{.+}}:
2025-03-25 12:57:42 +00:00
// CHECK-NEXT: .asciz "baz"
#[unsafe(no_mangle)]
pub fn manual_cstr() -> &'static str {
"baz\0"
}