@@ -67,6 +67,20 @@ public:
67
67
using TestTemplateInt = TestTemplate < int > ;
68
68
using TestTemplateBool = TestTemplate < bool > ;
69
69
70
+ using TestFunctionTy = int ( * _Nonnull) ( int) ;
71
+
72
+ inline TestFunctionTy getFreeFunctionThrowsPtr( ) noexcept {
73
+ return & freeFunctionThrows;
74
+ }
75
+
76
+ extern " C " {
77
+
78
+ typedef void ( * _Nonnull CFreeFunctionTy) ( void) ;
79
+
80
+ CFreeFunctionTy getCFreeFunctionPointer( ) noexcept;
81
+
82
+ }
83
+
70
84
//--- test.swift
71
85
72
86
import CxxModule
@@ -105,10 +119,22 @@ func testTemplateCalls() {
105
119
v2. dependentNoExceptMethod ( )
106
120
}
107
121
122
+ func testFuncPtrCall( ) {
123
+ let funcPtr = getFreeFunctionThrowsPtr ( )
124
+ let _ = funcPtr ( 2 )
125
+ }
126
+
127
+ func testCFuncPtrCall( ) {
128
+ let funcPtr = getCFreeFunctionPointer ( )
129
+ funcPtr ( )
130
+ }
131
+
108
132
let _ = testFreeFunctionNoThrowOnly ( )
109
133
let _ = testFreeFunctionCalls ( )
110
134
let _ = testMethodCalls ( )
111
135
testTemplateCalls ( )
136
+ testFuncPtrCall ( )
137
+ testCFuncPtrCall ( )
112
138
113
139
// CHECK: define {{.*}} @"$s4test0A23FreeFunctionNoThrowOnlys5Int32VyF"() #[[#SWIFTMETA:]] {
114
140
// CHECK-NEXT: :
@@ -182,6 +208,20 @@ testTemplateCalls()
182
208
// CHECK: [[CONT12]]:
183
209
// CHECK: ret
184
210
211
+ // CHECK: define {{.*}} @"$s4test0A11FuncPtrCallyyF"() #[[#SWIFTUWMETA]] personality
212
+ // CHECK: call i32 (i32)* @_Z24getFreeFunctionThrowsPtrv()
213
+ // CHECK: invoke i32 %{{.*}}(i32 2)
214
+ // CHECK-NEXT: to label %[[CONT20:.*]] unwind label %{{.*}}
215
+ // CHECK: [[CONT20]]:
216
+ // CHECK-NEXT: ret void
217
+
218
+ // CHECK: define {{.*}} @"$s4test0A12CFuncPtrCallyyF"() #[[#SWIFTUWMETA]] personality
219
+ // CHECK: call void ()* @getCFreeFunctionPointer()
220
+ // CHECK: invoke void %{{.*}}()
221
+ // CHECK-NEXT: to label %[[CONT21:.*]] unwind label %{{.*}}
222
+ // CHECK: [[CONT21]]:
223
+ // CHECK-NEXT: ret void
224
+
185
225
// CHECK: i32 @__gxx_personality_v0(...)
186
226
187
227
// CHECK: attributes #[[#SWIFTMETA]] = {
0 commit comments