]> git.lizzy.rs Git - rust.git/blob - src/test/ui/c-variadic/variadic-ffi-3.rs
c02d1f54e56492a3ca3c20dd4457f21e78dd73b3
[rust.git] / src / test / ui / c-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
18         let y: extern "C" fn(f: isize, x: u8, ...) = bar;
19         //~^ ERROR: mismatched types
20         //~| expected type `for<'r> extern "C" fn(isize, u8, std::ffi::VaList<'r>, ...)`
21
22         foo(1, 2, 3f32); //~ ERROR can't pass `f32` to variadic function
23         foo(1, 2, true); //~ ERROR can't pass `bool` to variadic function
24         foo(1, 2, 1i8); //~ ERROR can't pass `i8` to variadic function
25         foo(1, 2, 1u8); //~ ERROR can't pass `u8` to variadic function
26         foo(1, 2, 1i16); //~ ERROR can't pass `i16` to variadic function
27         foo(1, 2, 1u16); //~ ERROR can't pass `u16` to variadic function
28     }
29 }