Skip to content

Commit 402cb64

Browse files
[c-interop][test] Cover default argument values with @_extern
1 parent b62171a commit 402cb64

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

test/IRGen/extern_c.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ func test() {
55
explicit_extern_c()
66
// CHECK: call void @implicit_extern_c()
77
implicit_extern_c()
8+
// CHECK: [[DEFAULT_ARG:%[0-9]+]] = call swiftcc i32 @"$s8extern_c17default_arg_valueyys5Int32VFfA_"()
9+
// CHECK: call void @default_arg_value(i32 [[DEFAULT_ARG]])
10+
default_arg_value()
11+
// CHECK: call void @default_arg_value(i32 24)
12+
default_arg_value(24)
813
}
914

1015
test()
@@ -14,3 +19,6 @@ test()
1419

1520
// CHECK: declare void @implicit_extern_c()
1621
@_extern(c) func implicit_extern_c()
22+
23+
// CHECK: declare void @default_arg_value(i32)
24+
@_extern(c) func default_arg_value(_: Int32 = 42)

test/attr/attr_extern.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ func nonCParamTypesWasm(_: Int, _: NonC)
115115
@_extern(wasm, module: "non-c", name: "param_mixed")
116116
func nonCParamTypesMixed(_: Int, _: NonC) // expected-error {{'NonC' cannot be represented in C}}
117117
118+
@_extern(c)
119+
func defaultArgValue_C(_: Int = 42)
120+
121+
@_extern(wasm, module: "", name: "")
122+
func defaultArgValue_Wasm(_: Int = 24)
118123
119124
@_extern(c)
120125
func asyncFuncC() async // expected-error {{async functions cannot be represented in C}}

0 commit comments

Comments
 (0)