diff --git a/test/IRGen/Inputs/report_dead_method_call/main.swift b/test/IRGen/Inputs/report_dead_method_call/main.swift index dff2b7d9294c2..ca35bdd3f3b55 100644 --- a/test/IRGen/Inputs/report_dead_method_call/main.swift +++ b/test/IRGen/Inputs/report_dead_method_call/main.swift @@ -1,4 +1,8 @@ +// The StdlibUnittest test suite is placed here because it contains +// expressions that are only allowed at the top level in files named +// "main.swift". +import StdlibUnittest @inline(never) func testProto(_ c: Container) { @@ -27,16 +31,22 @@ func testPublicClass(_ c: PublicBase) { c.ghi() } -switch Process.argc { -case 1: - callClass() +let ReportDeadMethodCallTestSuite = TestSuite("ReportDeadMethodCall") -case 2: - callProto() +ReportDeadMethodCallTestSuite.test("Call class") { + expectCrashLater() + callClass() +} -case 3: - callPublicClass() +ReportDeadMethodCallTestSuite.test("Call proto") { + expectCrashLater() + callProto() +} -default: - break +ReportDeadMethodCallTestSuite.test("Call public class") { + expectCrashLater() + callPublicClass() } + +runAllTests() + diff --git a/test/IRGen/report_dead_method_call.swift b/test/IRGen/report_dead_method_call.swift index abce2943de59e..1f65efe6c622c 100644 --- a/test/IRGen/report_dead_method_call.swift +++ b/test/IRGen/report_dead_method_call.swift @@ -1,15 +1,15 @@ -// RUN: rm -rf %t && mkdir -p %t -// RUN: %target-build-swift %S/Inputs/report_dead_method_call/main.swift %s -O -Xfrontend -disable-access-control -o %t/a.out -// RUN: %target-run %t/a.out 2> %t/err1.log; FileCheck %s < %t/err1.log -// RUN: %target-run %t/a.out p1 2> %t/err2.log; FileCheck %s < %t/err2.log -// RUN: %target-run %t/a.out p1 p2 2> %t/err3.log; FileCheck %s < %t/err3.log -// REQUIRES: executable_test - +// RUN: rm -rf %t +// RUN: mkdir -p %t -// The -disable-access-control option let us "call" methods, which are removed -// by dead method elimination. +// We compile with -O (optimizations) and -disable-access-control (which +// allows use to "call" methods that are removed by dead code elimination). +// RUN: %target-build-swift %S/Inputs/report_dead_method_call/main.swift %s -O -Xfrontend -disable-access-control -o %t/report_dead_method_call -// CHECK: fatal error: call of deleted method +// The private, unused methods are optimized away. The test calls these +// methods anyway (since it has overridden the access control), so we +// expect them to produce "fatal error: call of deleted method" when run. +// RUN: %target-run %t/report_dead_method_call +// REQUIRES: executable_test private protocol PrivateProto { func abc()