]> git.proxmox.com Git - rustc.git/blob - src/test/ui/variadic-ffi-3.rs
New upstream version 1.29.0+dfsg1
[rustc.git] / src / test / ui / variadic-ffi-3.rs
1 // Copyright 2013 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 extern {
12 fn foo(f: isize, x: u8, ...);
13 //~^ defined here
14 //~| defined here
15 }
16
17 extern "C" fn bar(f: isize, x: u8) {}
18
19 fn main() {
20 unsafe {
21 foo(); //~ ERROR: this function takes at least 2 parameters but 0 parameters were supplied
22 foo(1); //~ ERROR: this function takes at least 2 parameters but 1 parameter was supplied
23
24 let x: unsafe extern "C" fn(f: isize, x: u8) = foo;
25 //~^ ERROR: mismatched types
26 //~| expected type `unsafe extern "C" fn(isize, u8)`
27 //~| found type `unsafe extern "C" fn(isize, u8, ...) {foo}`
28
29 let y: extern "C" fn(f: isize, x: u8, ...) = bar;
30 //~^ ERROR: mismatched types
31 //~| expected type `extern "C" fn(isize, u8, ...)`
32 //~| found type `extern "C" fn(isize, u8) {bar}`
33
34 foo(1, 2, 3f32); //~ ERROR can't pass `f32` to variadic function
35 foo(1, 2, true); //~ ERROR can't pass `bool` to variadic function
36 foo(1, 2, 1i8); //~ ERROR can't pass `i8` to variadic function
37 foo(1, 2, 1u8); //~ ERROR can't pass `u8` to variadic function
38 foo(1, 2, 1i16); //~ ERROR can't pass `i16` to variadic function
39 foo(1, 2, 1u16); //~ ERROR can't pass `u16` to variadic function
40 }
41 }