Skip to content

Commit

Permalink
Parse ... as a VaList
Browse files Browse the repository at this point in the history
  • Loading branch information
sholtrop authored and emilio committed May 29, 2023
1 parent 5778380 commit c8546ad
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/bindgen/ir/ty.rs
Expand Up @@ -535,6 +535,9 @@ impl Type {
}
return Err("Tuples are not supported types.".to_owned());
}
syn::Type::Verbatim(ref tokens) if tokens.to_string() == "..." => {
Type::Primitive(PrimitiveType::VaList)
}
_ => return Err(format!("Unsupported type: {:?}", ty)),
};

Expand Down
2 changes: 2 additions & 0 deletions tests/expectations/va_list.c
Expand Up @@ -4,3 +4,5 @@
#include <stdlib.h>

int32_t va_list_test(va_list ap);

int32_t va_list_test2(va_list ap);
2 changes: 2 additions & 0 deletions tests/expectations/va_list.compat.c
Expand Up @@ -9,6 +9,8 @@ extern "C" {

int32_t va_list_test(va_list ap);

int32_t va_list_test2(va_list ap);

#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
2 changes: 2 additions & 0 deletions tests/expectations/va_list.cpp
Expand Up @@ -8,4 +8,6 @@ extern "C" {

int32_t va_list_test(va_list ap);

int32_t va_list_test2(va_list ap);

} // extern "C"
2 changes: 2 additions & 0 deletions tests/expectations/va_list.pyx
Expand Up @@ -7,3 +7,5 @@ cdef extern from *:
cdef extern from *:

int32_t va_list_test(va_list ap);

int32_t va_list_test2(va_list ap);
5 changes: 5 additions & 0 deletions tests/rust/va_list.rs
Expand Up @@ -4,3 +4,8 @@ use std::ffi::VaList;
pub unsafe extern "C" fn va_list_test(mut ap: VaList) -> int32_t {
ap.arg()
}

#[no_mangle]
pub unsafe extern "C" fn va_list_test2(mut ap: ...) -> int32_t {
ap.arg()
}

0 comments on commit c8546ad

Please sign in to comment.