2025-04-17 16:07:12 +02:00
|
|
|
// 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
|
2025-04-08 15:17:08 +02:00
|
|
|
//@ compile-flags: --crate-type=lib -Copt-level=3
|
|
|
|
//@ edition: 2024
|
2025-03-25 12:57:42 +00:00
|
|
|
|
|
|
|
use std::ffi::CStr;
|
|
|
|
|
2025-04-14 09:49:43 +02:00
|
|
|
// CHECK: .section .rodata.str1.{{[12]}},"aMS"
|
2025-04-17 16:07:12 +02:00
|
|
|
// 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
|
2025-04-17 16:07:12 +02:00
|
|
|
// 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
|
2025-04-17 16:07:12 +02:00
|
|
|
// 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"
|
|
|
|
}
|