diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-07-21 14:22:51 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-07-22 14:27:48 +0200 |
| commit | ed93c1783b404d728d4809973a0550eb33cd293f (patch) | |
| tree | 2b62aab8b2482fcde1f9128ff53be8cd66bde847 /tests/assembly-llvm/cstring-merging.rs | |
| parent | c0b282f0ccdab7523cdb8dfa41b23bed5573da76 (diff) | |
| download | rust-ed93c1783b404d728d4809973a0550eb33cd293f.tar.gz rust-ed93c1783b404d728d4809973a0550eb33cd293f.zip | |
Rename `tests/assembly` into `tests/assembly-llvm`
Diffstat (limited to 'tests/assembly-llvm/cstring-merging.rs')
| -rw-r--r-- | tests/assembly-llvm/cstring-merging.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/assembly-llvm/cstring-merging.rs b/tests/assembly-llvm/cstring-merging.rs new file mode 100644 index 00000000000..03688e0068b --- /dev/null +++ b/tests/assembly-llvm/cstring-merging.rs @@ -0,0 +1,30 @@ +// MIPS assembler uses the label prefix `$anon.` for local anonymous variables +// other architectures (including ARM and x86-64) use the prefix `.Lanon.` +//@ only-linux +//@ assembly-output: emit-asm +//@ compile-flags: --crate-type=lib -Copt-level=3 -Cllvm-args=-enable-global-merge=0 +//@ edition: 2024 + +use std::ffi::CStr; + +// CHECK: .section .rodata.str1.{{[12]}},"aMS" +// CHECK: {{(\.L|\$)}}anon.{{.+}}: +// CHECK-NEXT: .asciz "foo" +#[unsafe(no_mangle)] +static CSTR: &[u8; 4] = b"foo\0"; + +// CHECK-NOT: .section +// CHECK: {{(\.L|\$)}}anon.{{.+}}: +// CHECK-NEXT: .asciz "bar" +#[unsafe(no_mangle)] +pub fn cstr() -> &'static CStr { + c"bar" +} + +// CHECK-NOT: .section +// CHECK: {{(\.L|\$)}}anon.{{.+}}: +// CHECK-NEXT: .asciz "baz" +#[unsafe(no_mangle)] +pub fn manual_cstr() -> &'static str { + "baz\0" +} |
