about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/abi/c-zst.aarch64-darwin.stderr (renamed from tests/ui/abi/c-zst.other-linux.stderr)0
-rw-r--r--tests/ui/abi/c-zst.rs80
-rw-r--r--tests/ui/abi/c-zst.x86_64-linux.stderr (renamed from tests/ui/abi/c-zst.other.stderr)0
-rw-r--r--tests/ui/abi/win64-zst.rs23
-rw-r--r--tests/ui/abi/win64-zst.x86_64-linux.stderr (renamed from tests/ui/abi/win64-zst.other.stderr)0
-rw-r--r--tests/ui/abi/win64-zst.x86_64-windows-gnu.stderr (renamed from tests/ui/abi/win64-zst.windows-gnu.stderr)0
6 files changed, 76 insertions, 27 deletions
diff --git a/tests/ui/abi/c-zst.other-linux.stderr b/tests/ui/abi/c-zst.aarch64-darwin.stderr
index 5a656e6ea66..5a656e6ea66 100644
--- a/tests/ui/abi/c-zst.other-linux.stderr
+++ b/tests/ui/abi/c-zst.aarch64-darwin.stderr
diff --git a/tests/ui/abi/c-zst.rs b/tests/ui/abi/c-zst.rs
index 0cfd653b37e..69ebefa09ac 100644
--- a/tests/ui/abi/c-zst.rs
+++ b/tests/ui/abi/c-zst.rs
@@ -1,27 +1,63 @@
-//@ revisions: other other-linux x86_64-pc-windows-gnu s390x-linux sparc64-linux powerpc-linux
 //@ normalize-stderr-test: "(abi|pref|unadjusted_abi_align): Align\([1-8] bytes\)" -> "$1: $$SOME_ALIGN"
-// ZSTs are only not ignored when the target_env is "gnu", "musl" or "uclibc". However, Rust does
-// not currently support any other target_env on these architectures.
-
-// Ignore the ZST revisions
-//@[other] ignore-x86_64-pc-windows-gnu
-//@[other] ignore-linux
-//@[other-linux] only-linux
-//@[other-linux] ignore-s390x
-//@[other-linux] ignore-sparc64
-//@[other-linux] ignore-powerpc
-
-// Pass the ZST indirectly revisions
-//@[x86_64-pc-windows-gnu] only-x86_64-pc-windows-gnu
-//@[s390x-linux] only-s390x
-//@[s390x-linux] only-linux
-//@[sparc64-linux] only-sparc64
-//@[sparc64-linux] only-linux
-//@[powerpc-linux] only-powerpc
-//@[powerpc-linux] only-linux
-
-#![feature(rustc_attrs)]
+/*!
+C doesn't have zero-sized types... except it does.
+
+Standard C doesn't, but some C compilers, like GCC, implement ZSTs as a compiler extension.
+This historically has wound up interacting with processor-specific ABIs in fairly ad-hoc ways.
+e.g. despite being "zero-sized", sometimes C compilers decide ZSTs consume registers.
+
+That means these two function signatures may not be compatible:
+
+```
+extern "C" fn((), i32, i32);
+extern "C" fn(i32, (), i32);
+```
+*/
+
+/*
+ * ZST IN "C" IS ZERO-SIZED
+ */
+
+//@ revisions: aarch64-darwin
+//@[aarch64-darwin] compile-flags: --target aarch64-apple-darwin
+//@[aarch64-darwin] needs-llvm-components: aarch64
+
+//@ revisions: x86_64-linux
+//@[x86_64-linux] compile-flags: --target x86_64-unknown-linux-gnu
+//@[x86_64-linux] needs-llvm-components: x86
+
+
+/*
+ * ZST IN "C" IS PASS-BY-POINTER
+ */
+
+// according to the SRV4 ABI, an aggregate is always passed in registers,
+// and it so happens the GCC extension for ZSTs considers them as structs.
+//@ revisions: powerpc-linux
+//@[powerpc-linux] compile-flags: --target powerpc-unknown-linux-gnu
+//@[powerpc-linux] needs-llvm-components: powerpc
+
+//@ revisions: s390x-linux
+//@[s390x-linux] compile-flags: --target s390x-unknown-linux-gnu
+//@[s390x-linux] needs-llvm-components: systemz
+
+//@ revisions: sparc64-linux
+//@[sparc64-linux] compile-flags: --target sparc64-unknown-linux-gnu
+//@[sparc64-linux] needs-llvm-components: sparc
+
+// The Win64 ABI uses slightly different handling for power-of-2 sizes in the ABI,
+// so GCC decided that ZSTs are pass-by-pointer, as `0.is_power_of_two() == false`
+//@ revisions: x86_64-pc-windows-gnu
+//@[x86_64-pc-windows-gnu] compile-flags: --target x86_64-pc-windows-gnu
+//@[x86_64-pc-windows-gnu] needs-llvm-components: x86
+
+
+#![feature(lang_items, no_core, rustc_attrs)]
+#![no_core]
 #![crate_type = "lib"]
 
+#[lang = "sized"]
+trait Sized {}
+
 #[rustc_abi(debug)]
 extern "C" fn pass_zst(_: ()) {} //~ ERROR: fn_abi
diff --git a/tests/ui/abi/c-zst.other.stderr b/tests/ui/abi/c-zst.x86_64-linux.stderr
index 5a656e6ea66..5a656e6ea66 100644
--- a/tests/ui/abi/c-zst.other.stderr
+++ b/tests/ui/abi/c-zst.x86_64-linux.stderr
diff --git a/tests/ui/abi/win64-zst.rs b/tests/ui/abi/win64-zst.rs
index cae32795e16..a2f7d19eb45 100644
--- a/tests/ui/abi/win64-zst.rs
+++ b/tests/ui/abi/win64-zst.rs
@@ -1,11 +1,24 @@
-//@ only-x86_64
-//@ revisions: other windows-gnu
 //@ normalize-stderr-test: "(abi|pref|unadjusted_abi_align): Align\([1-8] bytes\)" -> "$1: $$SOME_ALIGN"
-//@[other] ignore-windows-gnu
-//@[windows-gnu] only-windows-gnu
+//@ only-x86_64
+
+//@ revisions: x86_64-linux
+//@[x86_64-linux] compile-flags: --target x86_64-unknown-linux-gnu
+//@[x86_64-linux] needs-llvm-components: x86
 
-#![feature(rustc_attrs)]
+//@ revisions: x86_64-windows-gnu
+//@[x86_64-windows-gnu] compile-flags: --target x86_64-pc-windows-gnu
+//@[x86_64-windows-gnu] needs-llvm-components: x86
+
+//@ revisions: x86_64-windows-msvc
+//@[x86_64-windows-msvc] compile-flags: --target x86_64-pc-windows-msvc
+//@[x86_64-windows-msvc] needs-llvm-components: x86
+
+#![feature(no_core, lang_items, rustc_attrs)]
+#![no_core]
 #![crate_type = "lib"]
 
+#[lang = "sized"]
+trait Sized {}
+
 #[rustc_abi(debug)]
 extern "win64" fn pass_zst(_: ()) {} //~ ERROR: fn_abi
diff --git a/tests/ui/abi/win64-zst.other.stderr b/tests/ui/abi/win64-zst.x86_64-linux.stderr
index 15db141cb57..15db141cb57 100644
--- a/tests/ui/abi/win64-zst.other.stderr
+++ b/tests/ui/abi/win64-zst.x86_64-linux.stderr
diff --git a/tests/ui/abi/win64-zst.windows-gnu.stderr b/tests/ui/abi/win64-zst.x86_64-windows-gnu.stderr
index 7773e0aa2b5..7773e0aa2b5 100644
--- a/tests/ui/abi/win64-zst.windows-gnu.stderr
+++ b/tests/ui/abi/win64-zst.x86_64-windows-gnu.stderr