]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/extern-pass-empty.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / test / run-pass / extern-pass-empty.rs
CommitLineData
1a4d82fc
JJ
1// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11// Test a foreign function that accepts empty struct.
12
c34b1796 13// pretty-expanded FIXME #23616
c1a9b12d 14// ignore-msvc
abe05a73 15// ignore-emscripten emcc asserts on an empty struct as an argument
c34b1796 16
476ff2be 17#[repr(C)]
1a4d82fc
JJ
18struct TwoU8s {
19 one: u8,
20 two: u8,
21}
22
476ff2be 23#[repr(C)]
1a4d82fc
JJ
24struct ManyInts {
25 arg1: i8,
26 arg2: i16,
27 arg3: i32,
28 arg4: i16,
29 arg5: i8,
30 arg6: TwoU8s,
31}
32
476ff2be 33#[repr(C)]
1a4d82fc
JJ
34struct Empty;
35
476ff2be 36#[link(name = "rust_test_helpers", kind = "static")]
1a4d82fc
JJ
37extern {
38 fn rust_dbg_extern_empty_struct(v1: ManyInts, e: Empty, v2: ManyInts);
39}
40
41pub fn main() {
42 unsafe {
43 let x = ManyInts {
44 arg1: 2,
45 arg2: 3,
46 arg3: 4,
47 arg4: 5,
48 arg5: 6,
49 arg6: TwoU8s { one: 7, two: 8, }
50 };
51 let y = ManyInts {
52 arg1: 1,
53 arg2: 2,
54 arg3: 3,
55 arg4: 4,
56 arg5: 5,
57 arg6: TwoU8s { one: 6, two: 7, }
58 };
59 let empty = Empty;
60 rust_dbg_extern_empty_struct(x, empty, y);
61 }
62}