Add test and comment
This commit is contained in:
parent
a5fa12b6b9
commit
5c82a59bd3
2 changed files with 32 additions and 0 deletions
27
tests/assembly/cstring-merging.rs
Normal file
27
tests/assembly/cstring-merging.rs
Normal file
|
@ -0,0 +1,27 @@
|
|||
//@ only-linux
|
||||
//@ assembly-output: emit-asm
|
||||
//@ compile-flags: --crate-type=lib -Copt-level=3 --edition 2024
|
||||
|
||||
use std::ffi::CStr;
|
||||
|
||||
// CHECK: .section .rodata.str1.1,"aMS"
|
||||
// CHECK: .Lanon.{{.+}}:
|
||||
// CHECK-NEXT: .asciz "foo"
|
||||
#[unsafe(no_mangle)]
|
||||
static CSTR: &[u8; 4] = b"foo\0";
|
||||
|
||||
// CHECK-NOT: .section
|
||||
// CHECK: .Lanon.{{.+}}:
|
||||
// CHECK-NEXT: .asciz "bar"
|
||||
#[unsafe(no_mangle)]
|
||||
pub fn cstr() -> &'static CStr {
|
||||
c"bar"
|
||||
}
|
||||
|
||||
// CHECK-NOT: .section
|
||||
// CHECK: .Lanon.{{.+}}:
|
||||
// CHECK-NEXT: .asciz "baz"
|
||||
#[unsafe(no_mangle)]
|
||||
pub fn manual_cstr() -> &'static str {
|
||||
"baz\0"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue