]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/E0617.rs
New upstream version 1.24.1+dfsg1
[rustc.git] / src / test / compile-fail / E0617.rs
CommitLineData
041b39d2
XL
1// Copyright 2017 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// ignore-tidy-linelength
12
13extern {
14 fn printf(c: *const i8, ...);
15}
16
17fn main() {
18 unsafe {
19 printf(::std::ptr::null(), 0f32);
20 //~^ ERROR can't pass `f32` to variadic function, cast to `c_double` [E0617]
21 printf(::std::ptr::null(), 0i8);
22 //~^ ERROR can't pass `i8` to variadic function, cast to `c_int` [E0617]
23 printf(::std::ptr::null(), 0i16);
24 //~^ ERROR can't pass `i16` to variadic function, cast to `c_int` [E0617]
25 printf(::std::ptr::null(), 0u8);
26 //~^ ERROR can't pass `u8` to variadic function, cast to `c_uint` [E0617]
27 printf(::std::ptr::null(), 0u16);
28 //~^ ERROR can't pass `u16` to variadic function, cast to `c_uint` [E0617]
29 printf(::std::ptr::null(), printf);
30 //~^ ERROR can't pass `unsafe extern "C" fn(*const i8, ...) {printf}` to variadic function, cast to `unsafe extern "C" fn(*const i8, ...)` [E0617]
31 }
32}