Files
swift-mirror/test/Macros/SwiftifyImport/CountedBy/Nullable.swift
Henrik G. Olsson 27a29c0baf [Swiftify][StrictMemorySafety] Test unsafe warnings in wrappers (NFC) (#79719)
[Swiftify][StrictMemorySafety] Test `unsafe` warnings in wrappers (NFC)

As _SwiftifyImport now emits the `unsafe` keyword to prevent warnings
about unsafe code in the macro expansions, we should make sure that our
tests do not emit any warnings. It turns out that calls to
RawSpan::withUnsafeRawPointer are not recognised as unsafe, so we
sometimes get warnings about using `unsafe` on a safe expression. This
issue is tracked under rdar://145899513.
2025-03-03 17:56:12 -08:00

13 lines
613 B
Swift

// REQUIRES: swift_swift_parser
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "len"))
func myFunc(_ ptr: UnsafePointer<CInt>?, _ len: CInt) {
}
// CHECK: @_alwaysEmitIntoClient
// CHECK-NEXT: func myFunc(_ ptr: UnsafeBufferPointer<CInt>?) {
// CHECK-NEXT: return unsafe myFunc(ptr?.baseAddress, CInt(exactly: ptr?.count ?? 0)!)
// CHECK-NEXT: }