]> git.lizzy.rs Git - rust.git/blob - src/test/ui/variadic/variadic-ffi-3.rs
Ensure `record_layout_for_printing()` is inlined.
[rust.git] / src / test / ui / variadic / variadic-ffi-3.rs
1 extern {
2     fn foo(f: isize, x: u8, ...);
3     //~^ defined here
4     //~| defined here
5 }
6
7 extern "C" fn bar(f: isize, x: u8) {}
8
9 fn main() {
10     unsafe {
11         foo(); //~ ERROR: this function takes at least 2 parameters but 0 parameters were supplied
12         foo(1); //~ ERROR: this function takes at least 2 parameters but 1 parameter was supplied
13
14         let x: unsafe extern "C" fn(f: isize, x: u8) = foo;
15         //~^ ERROR: mismatched types
16         //~| expected type `unsafe extern "C" fn(isize, u8)`
17         //~| found type `unsafe extern "C" fn(isize, u8, ...) {foo}`
18
19         let y: extern "C" fn(f: isize, x: u8, ...) = bar;
20         //~^ ERROR: mismatched types
21         //~| expected type `extern "C" fn(isize, u8, ...)`
22         //~| found type `extern "C" fn(isize, u8) {bar}`
23
24         foo(1, 2, 3f32); //~ ERROR can't pass `f32` to variadic function
25         foo(1, 2, true); //~ ERROR can't pass `bool` to variadic function
26         foo(1, 2, 1i8); //~ ERROR can't pass `i8` to variadic function
27         foo(1, 2, 1u8); //~ ERROR can't pass `u8` to variadic function
28         foo(1, 2, 1i16); //~ ERROR can't pass `i16` to variadic function
29         foo(1, 2, 1u16); //~ ERROR can't pass `u16` to variadic function
30     }
31 }