Add E0617
This commit is contained in:
parent
03abb1bd70
commit
a5dc963974
4 changed files with 70 additions and 27 deletions
32
src/test/compile-fail/E0617.rs
Normal file
32
src/test/compile-fail/E0617.rs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// ignore-tidy-linelength
|
||||
|
||||
extern {
|
||||
fn printf(c: *const i8, ...);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
printf(::std::ptr::null(), 0f32);
|
||||
//~^ ERROR can't pass `f32` to variadic function, cast to `c_double` [E0617]
|
||||
printf(::std::ptr::null(), 0i8);
|
||||
//~^ ERROR can't pass `i8` to variadic function, cast to `c_int` [E0617]
|
||||
printf(::std::ptr::null(), 0i16);
|
||||
//~^ ERROR can't pass `i16` to variadic function, cast to `c_int` [E0617]
|
||||
printf(::std::ptr::null(), 0u8);
|
||||
//~^ ERROR can't pass `u8` to variadic function, cast to `c_uint` [E0617]
|
||||
printf(::std::ptr::null(), 0u16);
|
||||
//~^ ERROR can't pass `u16` to variadic function, cast to `c_uint` [E0617]
|
||||
printf(::std::ptr::null(), printf);
|
||||
//~^ ERROR can't pass `unsafe extern "C" fn(*const i8, ...) {printf}` to variadic function, cast to `unsafe extern "C" fn(*const i8, ...)` [E0617]
|
||||
}
|
||||
}
|
||||
|
|
@ -35,11 +35,11 @@ fn main() {
|
|||
//~| found type `extern "C" fn(isize, u8) {bar}`
|
||||
//~| NOTE: expected variadic fn, found non-variadic function
|
||||
|
||||
foo(1, 2, 3f32); //~ ERROR: can't pass an `f32` to variadic function, cast to `c_double`
|
||||
foo(1, 2, true); //~ ERROR: can't pass `bool` to variadic function, cast to `c_int`
|
||||
foo(1, 2, 1i8); //~ ERROR: can't pass `i8` to variadic function, cast to `c_int`
|
||||
foo(1, 2, 1u8); //~ ERROR: can't pass `u8` to variadic function, cast to `c_uint`
|
||||
foo(1, 2, 1i16); //~ ERROR: can't pass `i16` to variadic function, cast to `c_int`
|
||||
foo(1, 2, 1u16); //~ ERROR: can't pass `u16` to variadic function, cast to `c_uint`
|
||||
foo(1, 2, 3f32); //~ ERROR can't pass `f32` to variadic function, cast to `c_double`
|
||||
foo(1, 2, true); //~ ERROR can't pass `bool` to variadic function, cast to `c_int`
|
||||
foo(1, 2, 1i8); //~ ERROR can't pass `i8` to variadic function, cast to `c_int`
|
||||
foo(1, 2, 1u8); //~ ERROR can't pass `u8` to variadic function, cast to `c_uint`
|
||||
foo(1, 2, 1i16); //~ ERROR can't pass `i16` to variadic function, cast to `c_int`
|
||||
foo(1, 2, 1u16); //~ ERROR can't pass `u16` to variadic function, cast to `c_uint`
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue