Skip to content

Commit 613e545

Browse files
committed
[interop] test, add a test for trapping on exception in transparent thunk in Swift
1 parent a259a20 commit 613e545

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/Interop/Cxx/exceptions/trap-on-exception-irgen-itanium.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ CFreeFunctionTy getCFreeFunctionPointer() noexcept;
8181

8282
}
8383

84+
class ClassWithSubscript {
85+
int m = 0;
86+
public:
87+
int operator[](int x) const {
88+
return freeFunctionThrows(x);
89+
}
90+
};
91+
8492
//--- test.swift
8593

8694
import CxxModule
@@ -142,13 +150,19 @@ func testProtocolConformanceThunkInvoke() {
142150
let _ = p.method(2)
143151
}
144152

153+
func testSubscriptThunkInvoke() -> CInt {
154+
let v = ClassWithSubscript()
155+
return v[0]
156+
}
157+
145158
let _ = testFreeFunctionNoThrowOnly()
146159
let _ = testFreeFunctionCalls()
147160
let _ = testMethodCalls()
148161
testTemplateCalls()
149162
testFuncPtrCall()
150163
testCFuncPtrCall()
151164
testProtocolConformanceThunkInvoke()
165+
let _ = testSubscriptThunkInvoke()
152166

153167
// CHECK: define {{.*}} @"$s4test0A23FreeFunctionNoThrowOnlys5Int32VyF"() #[[#SWIFTMETA:]] {
154168
// CHECK-NEXT: :
@@ -253,6 +267,9 @@ testProtocolConformanceThunkInvoke()
253267
// CHECK-NOT: invoke
254268
// CHECK: }
255269

270+
// CHECK: define {{.*}} @"$s4test0A20SubscriptThunkInvokes5Int32VyF"() #[[#SWIFTUWMETA]]
271+
// CHECK: invoke i32 @_ZNK18ClassWithSubscriptixEi
272+
256273
// CHECK: i32 @__gxx_personality_v0(...)
257274

258275
// CHECK: attributes #[[#SWIFTMETA]] = {

0 commit comments

Comments
 (0)