Skip to content

Commit 289a4f5

Browse files
authored
Merge pull request #76653 from swiftlang/gaborh/unsafe_reference
[cxx-interop] Import SWIFT_UNSAFE_REFERENCE types as @unsafe
2 parents 2582883 + e8aea32 commit 289a4f5

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/ClangImporter/SwiftBridging/swift/bridging

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@
103103
#define SWIFT_UNSAFE_REFERENCE \
104104
__attribute__((swift_attr("import_reference"))) \
105105
__attribute__((swift_attr(_CXX_INTEROP_STRINGIFY(retain:immortal)))) \
106-
__attribute__((swift_attr(_CXX_INTEROP_STRINGIFY(release:immortal))))
106+
__attribute__((swift_attr(_CXX_INTEROP_STRINGIFY(release:immortal)))) \
107+
__attribute__((swift_attr("unsafe")))
107108

108109
/// Specifies a name that will be used in Swift for this declaration instead of its original name.
109110
#define SWIFT_NAME(_name) __attribute__((swift_name(#_name)))

test/Interop/Cxx/class/safe-interop-mode.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ struct SWIFT_ESCAPABLE Owner {};
2828

2929
struct Unannotated {};
3030

31+
struct SWIFT_UNSAFE_REFERENCE UnsafeReference {};
32+
3133
//--- test.swift
3234

3335
import Test
@@ -36,6 +38,10 @@ import CoreFoundation
3638
func useUnsafeParam(x: Unannotated) { // expected-warning{{reference to unsafe struct 'Unannotated'}}
3739
}
3840

41+
@available(macOS 13.4, *)
42+
func useUnsafeParam2(x: UnsafeReference) { // expected-warning{{reference to unsafe class 'UnsafeReference'}}
43+
}
44+
3945
func useSafeParams(x: Owner, y: View) {
4046
}
4147

0 commit comments

Comments
 (0)