Skip to content

Commit 7dbfc51

Browse files
committed
[interop] test, ensure we do not check for exceptions when exceptions are also disabled
1 parent 1dc0f01 commit 7dbfc51

File tree

4 files changed

+50
-9
lines changed

4 files changed

+50
-9
lines changed

test/Interop/Cxx/exceptions/exceptions-disabled-exception-irgen.swift

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,50 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: split-file %S/trap-on-exception-irgen-itanium.swift %t
2+
// RUN: split-file %s %t
33

4-
// RUN: %target-swift-emit-ir %t/test.swift -I %t -enable-experimental-cxx-interop -Xcc -fignore-exceptions | %FileCheck %s
4+
// RUN: %target-swift-emit-ir %t/test.swift -I %t/Inputs -enable-experimental-cxx-interop -Xcc -fignore-exceptions | %FileCheck %s
5+
// RUN: %target-swift-emit-ir %t/test.swift -I %t/Inputs -enable-experimental-cxx-interop -Xcc -fno-exceptions -Xcc -fno-objc-exceptions -Xcc -DNOEXCEPTION | %FileCheck %s
56

6-
// note: The test sources are in 'trap-on-exception-irgen-itanium.swift'
7+
//--- Inputs/module.modulemap
8+
module CxxModule {
9+
header "cxxHeader.h"
10+
requires cplusplus
11+
}
12+
13+
//--- Inputs/cxxHeader.h
14+
15+
inline int freeFunctionThrows(int x) {
16+
#ifndef NOEXCEPTION
17+
if (x > 0)
18+
throw 2;
19+
#endif
20+
return -x;
21+
}
22+
23+
inline int freeFunctionNoThrow(int x) noexcept {
24+
return -x;
25+
}
26+
27+
//--- test.swift
28+
29+
import CxxModule
30+
31+
func makeCInt() -> CInt {
32+
return 42
33+
}
34+
35+
func testFreeFunctionNoThrowOnly() -> CInt {
36+
return freeFunctionNoThrow(makeCInt())
37+
}
38+
39+
func testFreeFunctionCalls() -> CInt {
40+
let p = freeFunctionThrows(0)
41+
freeFunctionNoThrow(1)
42+
freeFunctionThrows(makeCInt())
43+
return p
44+
}
45+
46+
let _ = testFreeFunctionNoThrowOnly()
47+
let _ = testFreeFunctionCalls()
748

849
// CHECK: define {{.*}} @"$s4test0A23FreeFunctionNoThrowOnlys5Int32VyF"() #[[#SWIFTMETA:]] {
950
// CHECK-NEXT: :

test/Interop/Cxx/exceptions/trap-on-exception-execution.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// RUN: %empty-directory(%t)
22
// RUN: split-file %S/trap-on-exception-irgen-itanium.swift %t
33

4-
// RUN: %target-build-swift %s -I %t -o %t/trap-exceptions -Xfrontend -enable-experimental-cxx-interop -Xfrontend -validate-tbd-against-ir=none -g
4+
// RUN: %target-build-swift %s -I %t/Inputs -o %t/trap-exceptions -Xfrontend -enable-experimental-cxx-interop -Xfrontend -validate-tbd-against-ir=none -g
55
// RUN: %target-codesign %t/trap-exceptions
66
// RUN: %target-run %t/trap-exceptions
77

8-
// RUN: %target-build-swift %s -I %t -o %t/trap-exceptions-no-debug -Xfrontend -enable-experimental-cxx-interop -Xfrontend -validate-tbd-against-ir=none
8+
// RUN: %target-build-swift %s -I %t/Inputs -o %t/trap-exceptions-no-debug -Xfrontend -enable-experimental-cxx-interop -Xfrontend -validate-tbd-against-ir=none
99
// RUN: %target-codesign %t/trap-exceptions-no-debug
1010
// RUN: %target-run %t/trap-exceptions-no-debug
1111

12-
// RUN: %target-build-swift %s -I %t -o %t/trap-exceptions-opt -Xfrontend -enable-experimental-cxx-interop -Xfrontend -validate-tbd-against-ir=none -O
12+
// RUN: %target-build-swift %s -I %t/Inputs -o %t/trap-exceptions-opt -Xfrontend -enable-experimental-cxx-interop -Xfrontend -validate-tbd-against-ir=none -O
1313
// RUN: %target-codesign %t/trap-exceptions-opt
1414
// RUN: %target-run %t/trap-exceptions-opt
1515

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// RUN: %empty-directory(%t)
22
// RUN: split-file %s %t
33

4-
// RUN: %target-swift-emit-ir %t/test.swift -I %t -enable-experimental-cxx-interop | %FileCheck %s
5-
// RUN: %target-swift-emit-ir %t/test.swift -I %t -enable-experimental-cxx-interop -g | %FileCheck --check-prefix=DEBUG %s
4+
// RUN: %target-swift-emit-ir %t/test.swift -I %t/Inputs -enable-experimental-cxx-interop | %FileCheck %s
5+
// RUN: %target-swift-emit-ir %t/test.swift -I %t/Inputs -enable-experimental-cxx-interop -g | %FileCheck --check-prefix=DEBUG %s
66

77
// UNSUPPORTED: OS=windows-msvc
88

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %empty-directory(%t)
22
// RUN: split-file %S/trap-on-exception-irgen-itanium.swift %t
33

4-
// RUN: %target-swift-emit-ir %t/test.swift -I %t -enable-experimental-cxx-interop | %FileCheck %s
4+
// RUN: %target-swift-emit-ir %t/test.swift -I %t/Inputs -enable-experimental-cxx-interop | %FileCheck %s
55

66
// REQUIRES: OS=windows-msvc
77

0 commit comments

Comments
 (0)