File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-emit-silgen %s | %FileCheck %s
2
+
3
+ public class C { }
4
+
5
+ public struct BoxC {
6
+ let storage : AnyObject ?
7
+ let pointer : UnsafePointer < C >
8
+
9
+ subscript( ) -> C {
10
+ unsafeAddress {
11
+ pointer
12
+ }
13
+ }
14
+ }
15
+
16
+ // The addressor result must explicitly dependend on the apply's 'self' arg.
17
+ //
18
+ // CHECK-LABEL: sil [ossa] @$s20addressor_dependence21testAddressorLifetime3boxAA1CCAA4BoxCVn_tF : $@convention(thin) (@owned BoxC) -> @owned C {
19
+ // CHECK: bb0(%0 : @noImplicitCopy @_eagerMove @owned $BoxC):
20
+ // CHECK: [[MV:%.*]] = moveonlywrapper_to_copyable [guaranteed]
21
+ // CHECK: [[APPLY:%.*]] = apply %{{.*}}([[MV]]) : $@convention(method) (@guaranteed BoxC) -> UnsafePointer<C>
22
+ // CHECK: [[P:%.*]] = struct_extract [[APPLY]], #UnsafePointer._rawValue
23
+ // CHECK: [[A:%.*]] = pointer_to_address [[P]] to [strict] $*C
24
+ // CHECK: [[MD:%.*]] = mark_dependence [unresolved] [[A]] on [[MV]]
25
+ // CHECK: begin_access [read] [unsafe] [[MD]]
26
+ // CHECK-LABEL: } // end sil function '$s20addressor_dependence21testAddressorLifetime3boxAA1CCAA4BoxCVn_tF'
27
+ public func testAddressorLifetime( box: consuming BoxC ) -> C {
28
+ box [ ]
29
+ }
You can’t perform that action at this time.
0 commit comments