about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJubilee Young <workingjubilee@gmail.com>2024-06-22 14:42:26 -0700
committerJubilee Young <workingjubilee@gmail.com>2024-06-22 15:14:14 -0700
commit26dccadb476aaafa0930e6036c5583eea2c052e1 (patch)
tree65843fe14169b64f518246b09335a2f7ef9e4fb5
parenta0f01c3c1067aecb3d1ad88621bb4d63d0a2d289 (diff)
downloadrust-26dccadb476aaafa0930e6036c5583eea2c052e1.tar.gz
rust-26dccadb476aaafa0930e6036c5583eea2c052e1.zip
Allow "C-unwind" fn to have C variadics
-rw-r--r--compiler/rustc_ast_passes/src/ast_validation.rs1
-rw-r--r--compiler/rustc_span/src/symbol.rs1
-rw-r--r--tests/ui/abi/variadic-ffi.rs8
3 files changed, 10 insertions, 0 deletions
diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs
index e89b412687d..79717c969d7 100644
--- a/compiler/rustc_ast_passes/src/ast_validation.rs
+++ b/compiler/rustc_ast_passes/src/ast_validation.rs
@@ -637,6 +637,7 @@ impl<'a> AstValidator<'a> {
             (Some(FnCtxt::Foreign), _) => return,
             (Some(FnCtxt::Free), Some(header)) => match header.ext {
                 Extern::Explicit(StrLit { symbol_unescaped: sym::C, .. }, _)
+                | Extern::Explicit(StrLit { symbol_unescaped: sym::C_dash_unwind, .. }, _)
                 | Extern::Implicit(_)
                     if matches!(header.safety, Safety::Unsafe(_)) =>
                 {
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs
index a8123fe994c..8d8f4927e99 100644
--- a/compiler/rustc_span/src/symbol.rs
+++ b/compiler/rustc_span/src/symbol.rs
@@ -167,6 +167,7 @@ symbols! {
         Break,
         C,
         CStr,
+        C_dash_unwind: "C-unwind",
         CallOnceFuture,
         CallRefFuture,
         Capture,
diff --git a/tests/ui/abi/variadic-ffi.rs b/tests/ui/abi/variadic-ffi.rs
index de4844ac860..6cfae0f2a32 100644
--- a/tests/ui/abi/variadic-ffi.rs
+++ b/tests/ui/abi/variadic-ffi.rs
@@ -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())
 }
 
+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: ...) {
     let mut ap2 = ap.clone();
     assert_eq!(rust_valist_interesting_average(2, ap2.as_va_list()) as i64, 30);
@@ -73,6 +77,10 @@ pub fn main() {
     }
 
     unsafe {
+        assert_eq!(c_unwind_can_forward(2, 10i64, 10f64, 20i64, 20f64) as i64, 30);
+    }
+
+    unsafe {
         test_va_copy(4, 10i64, 10f64, 20i64, 20f64, 30i64, 30f64, 40i64, 40f64);
     }
 }