Files
swift-mirror/test/IRGen/c_function_pointer.sil
2023-06-21 10:10:32 -07:00

19 lines
776 B
Plaintext

// RUN: %target-swift-frontend -emit-ir %s | %FileCheck %s -DINT=i%target-ptrsize
import Swift
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} void @c_native_function_pointer(ptr %0)
sil @c_native_function_pointer : $@convention(c) (@convention(c) () -> ()) -> () {
entry(%f : $@convention(c) () -> ()):
return undef : $()
}
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @call_with_native_c_function_pointer(ptr %0)
sil @call_with_native_c_function_pointer : $@convention(thin) (@convention(c) () -> ()) -> () {
entry(%f : $@convention(c) () -> ()):
%c = function_ref @c_native_function_pointer : $@convention(c) (@convention(c) () -> ()) -> ()
%z = apply %c(%f) : $@convention(c) (@convention(c) () -> ()) -> ()
return %z : $()
}