Skip to content

Commit 75be0d6

Browse files
committed
Allow @safe(unchecked) on import decls
1 parent ba3e197 commit 75be0d6

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

include/swift/AST/DeclAttr.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ SIMPLE_DECL_ATTR(_addressableSelf, AddressableSelf,
529529

530530
DECL_ATTR(safe, Safe,
531531
OnAbstractFunction | OnSubscript | OnVar | OnMacro | OnNominalType |
532-
OnExtension | OnTypeAlias | UserInaccessible |
532+
OnExtension | OnTypeAlias | OnImport | UserInaccessible |
533533
ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove,
534534
163)
535535

test/Unsafe/unsafe_concurrency.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend -emit-module-path %t/unsafe_swift_decls.swiftmodule %S/Inputs/unsafe_swift_decls.swift -enable-experimental-feature AllowUnsafeAttribute
2+
// RUN: %target-swift-frontend -emit-module-path %t/unsafe_swift_decls.swiftmodule %S/Inputs/unsafe_swift_decls.swift -enable-experimental-feature AllowUnsafeAttribute -enable-experimental-feature AllowUnsafeAttribute
33

4-
// RUN: %target-typecheck-verify-swift -enable-experimental-feature WarnUnsafe -enable-experimental-feature StrictConcurrency -I %t
4+
// RUN: %target-typecheck-verify-swift -enable-experimental-feature WarnUnsafe -enable-experimental-feature StrictConcurrency -enable-experimental-feature AllowUnsafeAttribute -I %t
55

66
// REQUIRES: concurrency
77
// REQUIRES: swift_feature_StrictConcurrency
88
// REQUIRES: swift_feature_WarnUnsafe
9+
// REQUIRES: swift_feature_AllowUnsafeAttribute
910

1011
@preconcurrency import unsafe_swift_decls // expected-warning{{@preconcurrency import is not memory-safe because it can silently introduce data races; use '@safe(unchecked)' to assert that the code is memory-safe}}{{1-1=@safe(unchecked) }}
1112

13+
@safe(unchecked) @preconcurrency import unsafe_swift_decls // okay
14+
1215
class C: @unchecked Sendable {
1316
var counter: Int = 0
1417
}

0 commit comments

Comments
 (0)