mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The move-only checker relies on access markers to understand access scopes, so eliding them entirely leads to miscompiles. We can emit `begin_access [unsafe]` to semantically delimit exclusivity scopes while still doing no runtime checking. Fixes rdar://147546262.
26 lines
886 B
Swift
26 lines
886 B
Swift
// RUN: %target-swift-frontend -enforce-exclusivity=unchecked -emit-sil %s | %FileCheck %s
|
|
|
|
struct Foo: ~Copyable {
|
|
var x: Any
|
|
}
|
|
|
|
final class Bar {
|
|
init() { fatalError() }
|
|
|
|
// Ensure that noncopyable bindings still get [unsafe] exclusivity markers
|
|
// and get checked properly by the move-only checker.
|
|
|
|
// Bar.foo.setter:
|
|
// CHECK-LABEL: sil {{.*}} @$s{{.*}}3BarC3foo{{.*}}vs
|
|
// CHECK: [[FIELD:%.*]] = ref_element_addr {{.*}}, #Bar.foo
|
|
// CHECK: [[FIELD_ACCESS:%.*]] = begin_access [modify] [unsafe] [[FIELD]]
|
|
// CHECK-NEXT: destroy_addr [[FIELD_ACCESS]]
|
|
// CHECK-NEXT: copy_addr [take] {{.*}} to [init] [[FIELD_ACCESS]]
|
|
// CHECK-NEXT: end_access [[FIELD_ACCESS]]
|
|
// CHECK-NOT: [[FIELD]]
|
|
// CHECK-NOT: [[FIELD_ACCESS]]
|
|
// CHECK: } // end sil {{.*}} '$s{{.*}}3BarC3foo{{.*}}vs'
|
|
|
|
var foo: Foo
|
|
}
|