Allow variadic functions with cdecl calling convention.
This commit is contained in:
parent
c732446edd
commit
bf87e17cd6
5 changed files with 13 additions and 10 deletions
|
@ -4078,7 +4078,7 @@ register_diagnostics! {
|
||||||
// E0217, // ambiguous associated type, defined in multiple supertraits
|
// E0217, // ambiguous associated type, defined in multiple supertraits
|
||||||
// E0218, // no associated type defined
|
// E0218, // no associated type defined
|
||||||
// E0219, // associated type defined in higher-ranked supertrait
|
// E0219, // associated type defined in higher-ranked supertrait
|
||||||
// E0222, // Error code E0045 (variadic function must have C calling
|
// E0222, // Error code E0045 (variadic function must have C or cdecl calling
|
||||||
// convention) duplicate
|
// convention) duplicate
|
||||||
E0224, // at least one non-builtin train is required for an object type
|
E0224, // at least one non-builtin train is required for an object type
|
||||||
E0227, // ambiguous lifetime bound, explicit lifetime bound required
|
E0227, // ambiguous lifetime bound, explicit lifetime bound required
|
||||||
|
|
|
@ -141,11 +141,10 @@ fn require_c_abi_if_variadic(tcx: TyCtxt,
|
||||||
decl: &hir::FnDecl,
|
decl: &hir::FnDecl,
|
||||||
abi: Abi,
|
abi: Abi,
|
||||||
span: Span) {
|
span: Span) {
|
||||||
if decl.variadic && abi != Abi::C {
|
if decl.variadic && !(abi == Abi::C || abi == Abi::Cdecl) {
|
||||||
let mut err = struct_span_err!(tcx.sess, span, E0045,
|
let mut err = struct_span_err!(tcx.sess, span, E0045,
|
||||||
"variadic function must have C calling convention");
|
"variadic function must have C or cdecl calling convention");
|
||||||
err.span_label(span, "variadics require C calling conventions")
|
err.span_label(span, "variadics require C or cdecl calling convention").emit();
|
||||||
.emit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
extern "Rust" { fn foo(x: u8, ...); } //~ ERROR E0045
|
extern "Rust" { fn foo(x: u8, ...); } //~ ERROR E0045
|
||||||
//~| NOTE variadics require C calling conventions
|
//~| NOTE variadics require C or cdecl calling convention
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,10 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
fn baz(f: extern "cdecl" fn(usize, ...)) {
|
// ignore-arm stdcall isn't suppported
|
||||||
//~^ ERROR: variadic function must have C calling convention
|
|
||||||
|
fn baz(f: extern "stdcall" fn(usize, ...)) {
|
||||||
|
//~^ ERROR: variadic function must have C or cdecl calling convention
|
||||||
f(22, 44);
|
f(22, 44);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,10 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
extern "cdecl" {
|
// ignore-arm stdcall isn't suppported
|
||||||
fn printf(_: *const u8, ...); //~ ERROR: variadic function must have C calling convention
|
|
||||||
|
extern "stdcall" {
|
||||||
|
fn printf(_: *const u8, ...); //~ ERROR: variadic function must have C or cdecl calling
|
||||||
}
|
}
|
||||||
|
|
||||||
extern {
|
extern {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue