mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[wasm] Add support for __builtin_va_list type mapping (#84029)
Cover all va_list family of types just aliased by __builtin_va_list, including __isoc_va_list from wasi-libc. This enables proper C interop for variable argument functions on WASI targets. Close https://github.com/swiftlang/swift/issues/72398
This commit is contained in:
7
test/ClangImporter/Inputs/custom-modules/CVarArgs.h
Normal file
7
test/ClangImporter/Inputs/custom-modules/CVarArgs.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <stdarg.h>
|
||||
extern void takeVaList(va_list args);
|
||||
|
||||
extern void takeVaList2(__builtin_va_list args);
|
||||
|
||||
typedef __builtin_va_list my_builtin_va_list_alias;
|
||||
extern void takeVaList3(my_builtin_va_list_alias args);
|
||||
@@ -283,3 +283,8 @@ module Aliases {
|
||||
module RetroactiveVersioning {
|
||||
header "versioning.h"
|
||||
}
|
||||
|
||||
module CVarArgs {
|
||||
header "CVarArgs.h"
|
||||
export *
|
||||
}
|
||||
|
||||
18
test/ClangImporter/ctypes_valist_wasm.swift
Normal file
18
test/ClangImporter/ctypes_valist_wasm.swift
Normal file
@@ -0,0 +1,18 @@
|
||||
// RUN: %swift-frontend -target wasm32-unknown-wasip1 -parse-stdlib -module-name Swift -I %S/Inputs/custom-modules -typecheck %s
|
||||
|
||||
// REQUIRES: CODEGENERATOR=WebAssembly
|
||||
|
||||
import CVarArgs
|
||||
|
||||
/// ===== Minimal stdlib definitions =====
|
||||
typealias Void = ()
|
||||
struct CVaListPointer {}
|
||||
// Optional definition is required for isOptional check in ClangImporter
|
||||
enum Optional<T> {}
|
||||
/// ======================================
|
||||
|
||||
func testVaList() {
|
||||
let _: (CVaListPointer) -> Void = CVarArgs.takeVaList
|
||||
let _: (CVaListPointer) -> Void = CVarArgs.takeVaList2
|
||||
let _: (CVaListPointer) -> Void = CVarArgs.takeVaList3
|
||||
}
|
||||
Reference in New Issue
Block a user