Skip to content

Commit 27ecd84

Browse files
committed
Add some more tests
1 parent 1d69fe5 commit 27ecd84

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/SILOptimizer/moveonly_objectchecker_diagnostics.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,8 @@ public struct AggStruct {
758758

759759
public func aggStructUseMoveOnlyWithoutEscaping(_ x: AggStruct) {
760760
}
761+
public func useKlassPairWithoutConsuming(_ x: KlassPair) {
762+
}
761763
public func aggStructConsume(_ x: __owned AggStruct) {
762764
}
763765

@@ -1020,6 +1022,36 @@ public func aggStructConsumeGrandFieldOwnedArg(_ x2: __owned AggStruct) {
10201022
}
10211023
}
10221024

1025+
public func aggStructConsumeFieldNoError(_ x2: __owned AggStruct) {
1026+
if boolValue {
1027+
classConsume(x2.pair.lhs)
1028+
} else {
1029+
classConsume(x2.pair.rhs)
1030+
}
1031+
classConsume(x2.lhs)
1032+
}
1033+
1034+
public func aggStructConsumeFieldError(_ x2: __owned AggStruct) {
1035+
// expected-error @-1 {{'x2' has a move only field that was consumed before later uses}}
1036+
if boolValue {
1037+
classConsume(x2.lhs)
1038+
} else {
1039+
classConsume(x2.pair.rhs) // expected-note {{consuming use}}
1040+
}
1041+
useKlassPairWithoutConsuming(x2.pair) // expected-note {{boundary use here}}
1042+
}
1043+
1044+
public func aggStructConsumeFieldError2(_ x2: __owned AggStruct) {
1045+
// expected-error @-1 {{'x2' consumed more than once}}
1046+
if boolValue {
1047+
classConsume(x2.lhs) // expected-note {{consuming use}}
1048+
} else {
1049+
classConsume(x2.pair.rhs) // expected-note {{consuming use}}
1050+
}
1051+
aggStructConsume(x2) // expected-note {{consuming use}}
1052+
}
1053+
1054+
10231055
//////////////////////////////
10241056
// Aggregate Generic Struct //
10251057
//////////////////////////////

0 commit comments

Comments
 (0)