Skip to content

Commit eea6149

Browse files
committed
Enable varargs support for AAPCS calling convention
This is the default calling convention for ARM - it is used for extern "C", therefore it supports varargs.
1 parent ccf817b commit eea6149

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

compiler/rustc_hir_analysis/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ use rustc_hir::def::DefKind;
117117
fluent_messages! { "../messages.ftl" }
118118

119119
fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_>, decl: &hir::FnDecl<'_>, abi: Abi, span: Span) {
120-
const CONVENTIONS_UNSTABLE: &str = "`C`, `cdecl`, `win64`, `sysv64` or `efiapi`";
120+
const CONVENTIONS_UNSTABLE: &str = "`C`, `cdecl`, `aapcs`, `win64`, `sysv64` or `efiapi`";
121121
const CONVENTIONS_STABLE: &str = "`C` or `cdecl`";
122122
const UNSTABLE_EXPLAIN: &str =
123123
"using calling conventions other than `C` or `cdecl` for varargs functions is unstable";

compiler/rustc_target/src/spec/abi.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub enum Abi {
6868
impl Abi {
6969
pub fn supports_varargs(self) -> bool {
7070
// * C and Cdecl obviously support varargs.
71-
// * C can be based on SysV64 or Win64, so they must support varargs.
71+
// * C can be based on Aapcs, SysV64 or Win64, so they must support varargs.
7272
// * EfiApi is based on Win64 or C, so it also supports it.
7373
//
7474
// * Stdcall does not, because it would be impossible for the callee to clean
@@ -79,6 +79,7 @@ impl Abi {
7979
match self {
8080
Self::C { .. }
8181
| Self::Cdecl { .. }
82+
| Self::Aapcs { .. }
8283
| Self::Win64 { .. }
8384
| Self::SysV64 { .. }
8485
| Self::EfiApi => true,

tests/ui/c-variadic/variadic-ffi-2.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33

44
fn baz(f: extern "stdcall" fn(usize, ...)) {
55
//~^ ERROR: C-variadic function must have a compatible calling convention,
6-
// like C, cdecl, win64, sysv64 or efiapi
6+
// like C, cdecl, aapcs, win64, sysv64 or efiapi
77
f(22, 44);
88
}
99

10+
fn aapcs(f: extern "aapcs" fn(usize, ...)) {
11+
f(22, 44);
12+
}
1013
fn sysv(f: extern "sysv64" fn(usize, ...)) {
1114
f(22, 44);
1215
}

tests/ui/c-variadic/variadic-ffi-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0045]: C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `win64`, `sysv64` or `efiapi`
1+
error[E0045]: C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `aapcs`, `win64`, `sysv64` or `efiapi`
22
--> $DIR/variadic-ffi-2.rs:4:11
33
|
44
LL | fn baz(f: extern "stdcall" fn(usize, ...)) {

0 commit comments

Comments
 (0)