File tree Expand file tree Collapse file tree 2 files changed +29
-19
lines changed
Inputs/report_dead_method_call Expand file tree Collapse file tree 2 files changed +29
-19
lines changed Original file line number Diff line number Diff line change 1+ // The StdlibUnittest test suite is placed here because it contains
2+ // expressions that are only allowed at the top level in files named
3+ // "main.swift".
14
5+ import StdlibUnittest
26
37@inline ( never)
48func testProto( _ c: Container ) {
@@ -27,16 +31,22 @@ func testPublicClass(_ c: PublicBase) {
2731 c. ghi ( )
2832}
2933
30- switch Process . argc {
31- case 1 :
32- callClass ( )
34+ let ReportDeadMethodCallTestSuite = TestSuite ( " ReportDeadMethodCall " )
3335
34- case 2 :
35- callProto ( )
36+ ReportDeadMethodCallTestSuite . test ( " Call class " ) {
37+ expectCrashLater ( )
38+ callClass ( )
39+ }
3640
37- case 3 :
38- callPublicClass ( )
41+ ReportDeadMethodCallTestSuite . test ( " Call proto " ) {
42+ expectCrashLater ( )
43+ callProto ( )
44+ }
3945
40- default :
41- break
46+ ReportDeadMethodCallTestSuite . test ( " Call public class " ) {
47+ expectCrashLater ( )
48+ callPublicClass ( )
4249}
50+
51+ runAllTests ( )
52+
Original file line number Diff line number Diff line change 1- // RUN: rm -rf %t && mkdir -p %t
2- // RUN: %target-build-swift %S/Inputs/report_dead_method_call/main.swift %s -O -Xfrontend -disable-access-control -o %t/a.out
3- // RUN: %target-run %t/a.out 2> %t/err1.log; FileCheck %s < %t/err1.log
4- // RUN: %target-run %t/a.out p1 2> %t/err2.log; FileCheck %s < %t/err2.log
5- // RUN: %target-run %t/a.out p1 p2 2> %t/err3.log; FileCheck %s < %t/err3.log
6- // REQUIRES: executable_test
7-
1+ // RUN: rm -rf %t
2+ // RUN: mkdir -p %t
83
9- // The -disable-access-control option let us "call" methods, which are removed
10- // by dead method elimination.
4+ // We compile with -O (optimizations) and -disable-access-control (which
5+ // allows use to "call" methods that are removed by dead code elimination).
6+ // RUN: %target-build-swift %S/Inputs/report_dead_method_call/main.swift %s -O -Xfrontend -disable-access-control -o %t/report_dead_method_call
117
12- // CHECK: fatal error: call of deleted method
8+ // The private, unused methods are optimized away. The test calls these
9+ // methods anyway (since it has overridden the access control), so we
10+ // expect them to produce "fatal error: call of deleted method" when run.
11+ // RUN: %target-run %t/report_dead_method_call
12+ // REQUIRES: executable_test
1313
1414private protocol PrivateProto {
1515 func abc( )
You can’t perform that action at this time.
0 commit comments