diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/abi/issues | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/abi/issues')
4 files changed, 149 insertions, 0 deletions
diff --git a/tests/ui/abi/issues/issue-22565-rust-call.rs b/tests/ui/abi/issues/issue-22565-rust-call.rs new file mode 100644 index 000000000..a572666c8 --- /dev/null +++ b/tests/ui/abi/issues/issue-22565-rust-call.rs @@ -0,0 +1,31 @@ +#![feature(unboxed_closures)] + +extern "rust-call" fn b(_i: i32) {} +//~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument + +trait Tr { + extern "rust-call" fn a(); + //~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument + + extern "rust-call" fn b() {} + //~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument +} + +struct Foo; + +impl Foo { + extern "rust-call" fn bar() {} + //~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument +} + +impl Tr for Foo { + extern "rust-call" fn a() {} + //~^ ERROR functions with the "rust-call" ABI must take a single non-self tuple argument +} + +fn main() { + b(10); + Foo::bar(); + <Foo as Tr>::a(); + <Foo as Tr>::b(); +} diff --git a/tests/ui/abi/issues/issue-22565-rust-call.stderr b/tests/ui/abi/issues/issue-22565-rust-call.stderr new file mode 100644 index 000000000..9d205b444 --- /dev/null +++ b/tests/ui/abi/issues/issue-22565-rust-call.stderr @@ -0,0 +1,33 @@ +error[E0277]: functions with the "rust-call" ABI must take a single non-self tuple argument + --> $DIR/issue-22565-rust-call.rs:3:1 + | +LL | extern "rust-call" fn b(_i: i32) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Tuple` is not implemented for `i32` + +error: functions with the "rust-call" ABI must take a single non-self tuple argument + --> $DIR/issue-22565-rust-call.rs:17:5 + | +LL | extern "rust-call" fn bar() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: functions with the "rust-call" ABI must take a single non-self tuple argument + --> $DIR/issue-22565-rust-call.rs:22:5 + | +LL | extern "rust-call" fn a() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: functions with the "rust-call" ABI must take a single non-self tuple argument + --> $DIR/issue-22565-rust-call.rs:7:5 + | +LL | extern "rust-call" fn a(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: functions with the "rust-call" ABI must take a single non-self tuple argument + --> $DIR/issue-22565-rust-call.rs:10:5 + | +LL | extern "rust-call" fn b() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/abi/issues/issue-62350-sysv-neg-reg-counts.rs b/tests/ui/abi/issues/issue-62350-sysv-neg-reg-counts.rs new file mode 100644 index 000000000..29b240518 --- /dev/null +++ b/tests/ui/abi/issues/issue-62350-sysv-neg-reg-counts.rs @@ -0,0 +1,46 @@ +// run-pass +#![allow(dead_code)] +#![allow(improper_ctypes)] + +// ignore-wasm32-bare no libc to test ffi with + +#[derive(Copy, Clone)] +pub struct QuadFloats { + a: f32, + b: f32, + c: f32, + d: f32, +} + +mod rustrt { + use super::QuadFloats; + + #[link(name = "rust_test_helpers", kind = "static")] + extern "C" { + pub fn get_c_exhaust_sysv64_ints( + _: *const (), + _: *const (), + _: *const (), + _: *const (), + _: *const (), + _: *const (), + _: *const (), + h: QuadFloats, + ) -> f32; + } +} + +fn test() { + unsafe { + let null = std::ptr::null(); + let q = QuadFloats { a: 10.2, b: 20.3, c: 30.4, d: 40.5 }; + assert_eq!( + rustrt::get_c_exhaust_sysv64_ints(null, null, null, null, null, null, null, q), + q.c, + ); + } +} + +pub fn main() { + test(); +} diff --git a/tests/ui/abi/issues/issue-97463-broken-abi-leaked-uninit-data.rs b/tests/ui/abi/issues/issue-97463-broken-abi-leaked-uninit-data.rs new file mode 100644 index 000000000..fba880d4f --- /dev/null +++ b/tests/ui/abi/issues/issue-97463-broken-abi-leaked-uninit-data.rs @@ -0,0 +1,39 @@ +// run-pass +// ignore-wasm +#![allow(dead_code)] +#![allow(improper_ctypes)] + +#[link(name = "rust_test_helpers", kind = "static")] +extern "C" { + pub fn issue_97463_leak_uninit_data(a: u32, b: u32, c: u32) -> u16; +} + +fn main() { + const C1: usize = 0x327b23c6; + const C2: usize = C1 & 0xFFFF; + + let r1: usize = 0x0; + let r2: usize = C1; + let r3: usize = 0x0; + let value: u16 = unsafe { issue_97463_leak_uninit_data(r1 as u32, r2 as u32, r3 as u32) }; + + // NOTE: as an example of the sensitivity of this test to optimization choices, + // uncommenting this block of code makes the bug go away on pnkfelix's machine. + // (But observing via `dbg!` doesn't hide the bug. At least sometimes.) + /* + println!("{}", value); + println!("{}", value as usize); + println!("{}", usize::from(value)); + println!("{}", (value as usize) & 0xFFFF); + */ + + let d1 = value; + let d2 = value as usize; + let d3 = usize::from(value); + let d4 = (value as usize) & 0xFFFF; + + let d = (&d1, &d2, &d3, &d4); + let d_ = (d1, d2, d3, d4); + + assert_eq!(((&(C2 as u16), &C2, &C2, &C2), (C2 as u16, C2, C2, C2)), (d, d_)); +} |