You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/SILOptimizer/moveonly_addresschecker_diagnostics.swift
+86Lines changed: 86 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -89,6 +89,7 @@ public final class CopyableKlassWithMoveOnlyField {
89
89
90
90
publicprotocolP{
91
91
staticvarvalue:Self{get}
92
+
varname:CopyableKlass{get}
92
93
staticvarvalue2:anyP{get}
93
94
}
94
95
@@ -110,6 +111,7 @@ public struct AddressOnlyGeneric<T : P> {
110
111
extensionCopyableKlass:P{
111
112
publicstaticvarvalue:Self{fatalError()}
112
113
publicstaticvarvalue2:anyP{CopyableKlass()}
114
+
publicvarname:CopyableKlass{CopyableKlass()}
113
115
}
114
116
115
117
@_moveOnly
@@ -2359,6 +2361,39 @@ public func addressOnlyGenericAccessConsumeField2<T>(_ x: borrowing AddressOnlyG
2359
2361
}
2360
2362
}
2361
2363
2364
+
publicfunc addressOnlyGenericAccessConsumeGrandField<T>(_ x:borrowingAddressOnlyGeneric<T>){ // expected-error {{'x' has guaranteed ownership but was consumed}}
2365
+
varx2= x // expected-note {{consuming use here}}
2366
+
x2 =AddressOnlyGeneric<T>()
2367
+
2368
+
consumeVal(x2.copyable.name)
2369
+
for_in0..<1024{
2370
+
consumeVal(x2.copyable.name)
2371
+
}
2372
+
}
2373
+
2374
+
publicfunc addressOnlyGenericAccessConsumeGrandField2<T>(_ x:borrowingAddressOnlyGeneric<T>){ // expected-error {{'x' has guaranteed ownership but was consumed}}
2375
+
varx2= x // expected-note {{consuming use here}}
2376
+
// expected-error @-1 {{'x2' consumed more than once}}
2377
+
// expected-error @-2 {{'x2' consumed by a use in a loop}}
2378
+
x2 =AddressOnlyGeneric<T>()
2379
+
2380
+
consumeVal(x2.moveOnly.k) // expected-note {{consuming use here}}
2381
+
for_in0..<1024{
2382
+
consumeVal(x2.moveOnly.k) // expected-note {{consuming use here}}
2383
+
// expected-note @-1 {{consuming use here}}
2384
+
}
2385
+
}
2386
+
2387
+
publicfunc addressOnlyGenericAccessConsumeGrandField2a<T>(_ x:borrowingAddressOnlyGeneric<T>){ // expected-error {{'x' has guaranteed ownership but was consumed}}
0 commit comments