mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Allow "C-unwind" fn to have C variadics
This commit is contained in:
parent
a0f01c3c10
commit
26dccadb47
@ -637,6 +637,7 @@ impl<'a> AstValidator<'a> {
|
|||||||
(Some(FnCtxt::Foreign), _) => return,
|
(Some(FnCtxt::Foreign), _) => return,
|
||||||
(Some(FnCtxt::Free), Some(header)) => match header.ext {
|
(Some(FnCtxt::Free), Some(header)) => match header.ext {
|
||||||
Extern::Explicit(StrLit { symbol_unescaped: sym::C, .. }, _)
|
Extern::Explicit(StrLit { symbol_unescaped: sym::C, .. }, _)
|
||||||
|
| Extern::Explicit(StrLit { symbol_unescaped: sym::C_dash_unwind, .. }, _)
|
||||||
| Extern::Implicit(_)
|
| Extern::Implicit(_)
|
||||||
if matches!(header.safety, Safety::Unsafe(_)) =>
|
if matches!(header.safety, Safety::Unsafe(_)) =>
|
||||||
{
|
{
|
||||||
|
@ -167,6 +167,7 @@ symbols! {
|
|||||||
Break,
|
Break,
|
||||||
C,
|
C,
|
||||||
CStr,
|
CStr,
|
||||||
|
C_dash_unwind: "C-unwind",
|
||||||
CallOnceFuture,
|
CallOnceFuture,
|
||||||
CallRefFuture,
|
CallRefFuture,
|
||||||
Capture,
|
Capture,
|
||||||
|
@ -14,6 +14,10 @@ pub unsafe extern "C" fn test_valist_forward(n: u64, mut ap: ...) -> f64 {
|
|||||||
rust_valist_interesting_average(n, ap.as_va_list())
|
rust_valist_interesting_average(n, ap.as_va_list())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub unsafe extern "C-unwind" fn c_unwind_can_forward(n: u64, mut ap: ...) -> f64 {
|
||||||
|
rust_valist_interesting_average(n, ap.as_va_list())
|
||||||
|
}
|
||||||
|
|
||||||
pub unsafe extern "C" fn test_va_copy(_: u64, mut ap: ...) {
|
pub unsafe extern "C" fn test_va_copy(_: u64, mut ap: ...) {
|
||||||
let mut ap2 = ap.clone();
|
let mut ap2 = ap.clone();
|
||||||
assert_eq!(rust_valist_interesting_average(2, ap2.as_va_list()) as i64, 30);
|
assert_eq!(rust_valist_interesting_average(2, ap2.as_va_list()) as i64, 30);
|
||||||
@ -72,6 +76,10 @@ pub fn main() {
|
|||||||
assert_eq!(test_valist_forward(2, 10i64, 10f64, 20i64, 20f64) as i64, 30);
|
assert_eq!(test_valist_forward(2, 10i64, 10f64, 20i64, 20f64) as i64, 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
assert_eq!(c_unwind_can_forward(2, 10i64, 10f64, 20i64, 20f64) as i64, 30);
|
||||||
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
test_va_copy(4, 10i64, 10f64, 20i64, 20f64, 30i64, 30f64, 40i64, 40f64);
|
test_va_copy(4, 10i64, 10f64, 20i64, 20f64, 30i64, 30f64, 40i64, 40f64);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user