Files
swift-mirror/test/Interpreter/unavailable_decl_optimization_stub.swift
Allan Shortlidge d1416ddd56 SILGen: Stub unavailable functions.
When `-unavailable-decl-optimization=stub` is specified, insert a call to
`_diagnoseUnavailableCodeReached()` at the beginning of the function to cause
it to trap if executed at run time.

Part of rdar://107388493
2023-05-03 15:19:31 -07:00

22 lines
605 B
Swift

// RUN: %empty-directory(%t)
// RUN: %target-build-swift -module-name main -Xfrontend -unavailable-decl-optimization=stub %s -o %t/a.out
// RUN: %target-codesign %t/a.out
// RUN: %target-run %t/a.out > %t/output 2>&1 || true
// RUN: %FileCheck %s < %t/output
// REQUIRES: executable_test
@available(*, unavailable)
public func foo() {
print("Can't call this")
}
// To bypass the typechecker, forward declare an available function with the
// same mangling as foo.
@_silgen_name("$s4main3fooyyF")
func callFoo()
// CHECK: Fatal error: Unavailable code reached
// CHECK-NOT: Can't call this
callFoo()