mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
PrintAsObjC Test: Test pointer types with @cdecl
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
|
||||
//--- Lib.swift
|
||||
|
||||
// CHECK-NOT: assume_nonnull
|
||||
|
||||
// CHECK: #if defined(__cplusplus)
|
||||
// CHECK: extern "C" {
|
||||
// CHECK: #endif
|
||||
@@ -43,6 +45,23 @@ func c_keywordArgNames(auto: Int, union: Int) {}
|
||||
func d_returnNever() -> Never { fatalError() }
|
||||
// CHECK-LABEL: SWIFT_EXTERN void return_never(void) SWIFT_NOEXCEPT SWIFT_NORETURN;
|
||||
|
||||
/// Pointer types
|
||||
// CHECK: /// Pointer types
|
||||
|
||||
@cdecl("pointers")
|
||||
func f_pointers(_ x: UnsafeMutablePointer<Int>,
|
||||
y: UnsafePointer<Int>,
|
||||
z: UnsafeMutableRawPointer,
|
||||
w: UnsafeRawPointer,
|
||||
u: OpaquePointer) {}
|
||||
// CHECK: SWIFT_EXTERN void pointers(ptrdiff_t * _Nonnull x, ptrdiff_t const * _Nonnull y, void * _Nonnull z, void const * _Nonnull w, void * _Nonnull u) SWIFT_NOEXCEPT;
|
||||
|
||||
@cdecl("nullable_pointers")
|
||||
func g_nullablePointers(_ x: UnsafeMutableRawPointer,
|
||||
y: UnsafeMutableRawPointer?,
|
||||
z: UnsafeMutableRawPointer!) {}
|
||||
// CHECK: SWIFT_EXTERN void nullable_pointers(void * _Nonnull x, void * _Nullable y, void * _Null_unspecified z) SWIFT_NOEXCEPT;
|
||||
|
||||
// CHECK: #if defined(__cplusplus)
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: #endif
|
||||
|
||||
@@ -55,3 +55,19 @@ class Foo {
|
||||
|
||||
@cdecl("throwing") // expected-error{{raising errors from @cdecl functions is not supported}}
|
||||
func throwing() throws { }
|
||||
|
||||
@cdecl("acceptedPointers")
|
||||
func acceptedPointers(_ x: UnsafeMutablePointer<Int>,
|
||||
y: UnsafePointer<Int>,
|
||||
z: UnsafeMutableRawPointer,
|
||||
w: UnsafeRawPointer,
|
||||
u: OpaquePointer) {}
|
||||
|
||||
@cdecl("rejectedPointers")
|
||||
func rejectedPointers( // expected-error 6 {{global function cannot be marked '@cdecl' because the type of the parameter}}
|
||||
x: UnsafePointer<String>, // expected-note {{Swift structs cannot be represented in Objective-C}} // FIXME: Should reference C.
|
||||
y: CVaListPointer, // expected-note {{Swift structs cannot be represented in Objective-C}}
|
||||
z: UnsafeBufferPointer<Int>, // expected-note {{Swift structs cannot be represented in Objective-C}}
|
||||
u: UnsafeMutableBufferPointer<Int>, // expected-note {{Swift structs cannot be represented in Objective-C}}
|
||||
v: UnsafeRawBufferPointer, // expected-note {{Swift structs cannot be represented in Objective-C}}
|
||||
t: UnsafeMutableRawBufferPointer) {} // expected-note {{Swift structs cannot be represented in Objective-C}}
|
||||
|
||||
Reference in New Issue
Block a user