]>
Commit | Line | Data |
---|---|---|
b7449926 XL |
1 | // run-pass |
2 | #![allow(improper_ctypes)] // FIXME: this test is inherently not FFI-safe. | |
3 | ||
1a4d82fc JJ |
4 | // Test a foreign function that accepts empty struct. |
5 | ||
c34b1796 | 6 | // pretty-expanded FIXME #23616 |
c1a9b12d | 7 | // ignore-msvc |
abe05a73 | 8 | // ignore-emscripten emcc asserts on an empty struct as an argument |
c34b1796 | 9 | |
476ff2be | 10 | #[repr(C)] |
1a4d82fc JJ |
11 | struct TwoU8s { |
12 | one: u8, | |
13 | two: u8, | |
14 | } | |
15 | ||
476ff2be | 16 | #[repr(C)] |
1a4d82fc JJ |
17 | struct ManyInts { |
18 | arg1: i8, | |
19 | arg2: i16, | |
20 | arg3: i32, | |
21 | arg4: i16, | |
22 | arg5: i8, | |
23 | arg6: TwoU8s, | |
24 | } | |
25 | ||
476ff2be | 26 | #[repr(C)] |
1a4d82fc JJ |
27 | struct Empty; |
28 | ||
476ff2be | 29 | #[link(name = "rust_test_helpers", kind = "static")] |
1a4d82fc JJ |
30 | extern { |
31 | fn rust_dbg_extern_empty_struct(v1: ManyInts, e: Empty, v2: ManyInts); | |
32 | } | |
33 | ||
34 | pub fn main() { | |
35 | unsafe { | |
36 | let x = ManyInts { | |
37 | arg1: 2, | |
38 | arg2: 3, | |
39 | arg3: 4, | |
40 | arg4: 5, | |
41 | arg5: 6, | |
42 | arg6: TwoU8s { one: 7, two: 8, } | |
43 | }; | |
44 | let y = ManyInts { | |
45 | arg1: 1, | |
46 | arg2: 2, | |
47 | arg3: 3, | |
48 | arg4: 4, | |
49 | arg5: 5, | |
50 | arg6: TwoU8s { one: 6, two: 7, } | |
51 | }; | |
52 | let empty = Empty; | |
53 | rust_dbg_extern_empty_struct(x, empty, y); | |
54 | } | |
55 | } |