Skip to content

Commit ab75611

Browse files
committed
Test: update tests with no-op consumes
1 parent e04b35d commit ab75611

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

test/Parse/move_expr.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
var global: Int = 5
44
func testGlobal() {
5-
let _ = consume global
5+
let _ = consume global // expected-warning {{'consume' applied to bitwise-copyable type 'Int' has no effect}}
66
}
77

88
func testLet() {

test/SILOptimizer/consume_operator_kills_copyable_loadable_vars.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,14 @@ func consumeInitdArray() {
725725
func isNegative(_ c: consuming Int) -> Bool { return c < 0 }
726726
func consumeInt() {
727727
var g = 0 // expected-warning{{variable 'g' was never mutated; consider changing to 'let' constant}}
728-
isNegative(consume g) // expected-warning{{result of call to 'isNegative' is unused}}
728+
// expected-error@-1 {{'g' used after consume}}
729+
730+
_ = isNegative(consume g) // expected-note {{consumed here}}
731+
// expected-warning@-1 {{'consume' applied to bitwise-copyable type 'Int' has no effect}}
732+
733+
_ = isNegative(consume g) // expected-note {{used here}}
734+
// expected-error@-1 {{'consume' applied to value that the compiler does not support. This is a compiler bug. Please file a bug with a small example of the bug}}
735+
// expected-warning@-2 {{'consume' applied to bitwise-copyable type 'Int' has no effect}}
729736
}
730737

731738
//////////////////////

test/Sema/move_expr.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Klass {
66

77
var global: Int = 5
88
func testGlobal() {
9-
let _ = consume global
9+
let _ = consume global // expected-warning {{'consume' applied to bitwise-copyable type 'Int' has no effect}}
1010
}
1111

1212
func testLet() {
@@ -23,14 +23,14 @@ func testVar() {
2323
func testExprFailureLet() {
2424
let t = 5
2525
// Next line is parsed as move(t) + t
26-
let _ = consume t + t
26+
let _ = consume t + t // expected-warning {{'consume' applied to bitwise-copyable type 'Int' has no effect}}
2727
}
2828

2929
func testExprFailureVar() {
3030
var t = 5
3131
t = 5
3232
// Next line is parsed as move(t) + t
33-
let _ = consume t + t
33+
let _ = consume t + t // expected-warning {{'consume' applied to bitwise-copyable type 'Int' has no effect}}
3434
}
3535

3636
func letAddressOnly<T>(_ v: T) {

0 commit comments

Comments
 (0)