]>
Commit | Line | Data |
---|---|---|
9346a6ac AL |
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 | } | |
14 | ||
15 | extern "C" fn bar(f: isize, x: u8) {} | |
16 | ||
17 | fn main() { | |
18 | unsafe { | |
19 | foo(); //~ ERROR: this function takes at least 2 parameters but 0 parameters were supplied | |
20 | foo(1); //~ ERROR: this function takes at least 2 parameters but 1 parameter was supplied | |
21 | ||
22 | let x: unsafe extern "C" fn(f: isize, x: u8) = foo; | |
23 | //~^ ERROR: mismatched types | |
24 | //~| expected `unsafe extern "C" fn(isize, u8)` | |
54a0048b | 25 | //~| found `unsafe extern "C" fn(isize, u8, ...) {foo}` |
9346a6ac AL |
26 | //~| expected non-variadic fn |
27 | //~| found variadic function | |
28 | ||
29 | let y: extern "C" fn(f: isize, x: u8, ...) = bar; | |
30 | //~^ ERROR: mismatched types | |
31 | //~| expected `extern "C" fn(isize, u8, ...)` | |
32 | //~| found `extern "C" fn(isize, u8) {bar}` | |
33 | //~| expected variadic fn | |
34 | //~| found non-variadic function | |
35 | ||
54a0048b SL |
36 | foo(1, 2, 3f32); //~ ERROR: can't pass an `f32` to variadic function, cast to `c_double` |
37 | foo(1, 2, true); //~ ERROR: can't pass `bool` to variadic function, cast to `c_int` | |
38 | foo(1, 2, 1i8); //~ ERROR: can't pass `i8` to variadic function, cast to `c_int` | |
39 | foo(1, 2, 1u8); //~ ERROR: can't pass `u8` to variadic function, cast to `c_uint` | |
40 | foo(1, 2, 1i16); //~ ERROR: can't pass `i16` to variadic function, cast to `c_int` | |
41 | foo(1, 2, 1u16); //~ ERROR: can't pass `u16` to variadic function, cast to `c_uint` | |
9346a6ac AL |
42 | } |
43 | } |