about summary refs log tree commit diff
path: root/tests/assembly/cstring-merging.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/assembly/cstring-merging.rs')
-rw-r--r--tests/assembly/cstring-merging.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/assembly/cstring-merging.rs b/tests/assembly/cstring-merging.rs
new file mode 100644
index 00000000000..7436e241823
--- /dev/null
+++ b/tests/assembly/cstring-merging.rs
@@ -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"
+}