Skip to content

Commit 783ab96

Browse files
committed
Fixing broken tests.
Usage of 'defer' now emits a warning in some places in the tests, so adding the corresponding 'expected-warning'.
1 parent 38cf5fe commit 783ab96

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

test/SILGen/statements.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ func defer_in_closure_in_generic<T>(_ x: T) {
524524
// CHECK-LABEL: sil private @$S10statements017defer_in_closure_C8_genericyyxlFyycfU_ : $@convention(thin) <T> () -> ()
525525
_ = {
526526
// CHECK-LABEL: sil private @$S10statements017defer_in_closure_C8_genericyyxlFyycfU_6$deferL_yylF : $@convention(thin) <T> () -> ()
527-
defer { generic_callee_1(T.self) }
527+
defer { generic_callee_1(T.self) } // expected-warning {{'defer' at the end of its scope is redundant and will execute immediately}}{{5-10=do}}
528528
}
529529
}
530530

@@ -537,7 +537,7 @@ func defer_mutable(_ x: Int) {
537537
// CHECK: function_ref @$S10statements13defer_mutableyySiF6$deferL_yyF : $@convention(thin) (@inout_aliasable Int) -> ()
538538
// CHECK-NOT: [[BOX]]
539539
// CHECK: destroy_value [[BOX]]
540-
defer { _ = x }
540+
defer { _ = x } // expected-warning {{'defer' at the end of its scope is redundant and will execute immediately}}{{3-8=do}}
541541
}
542542

543543
protocol StaticFooProtocol { static func foo() }

test/SILOptimizer/definite_init_diagnostics_globals.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ defer { print(y) } // expected-error {{constant 'y' used in defer before being i
2121
// Test top-level functions.
2222

2323
func testFunc() { // expected-error {{variable 'x' used by function definition before being initialized}}
24-
defer { print(x) }
24+
defer { print(x) } // expected-warning {{'defer' at the end of its scope is redundant and will execute immediately}}{{3-8=do}}
2525
}
2626

2727
// Test top-level closures.

test/SILOptimizer/unreachable_code.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ func deferTryNoReturn() throws {
285285
}
286286

287287
func noReturnInDefer() {
288-
defer {
288+
defer { // expected-warning {{'defer' at the end of its scope is redundant and will execute immediately}}{{3-8=do}}
289289
_ = Lisp()
290290
die() // expected-note {{a call to a never-returning function}}
291291
die() // expected-warning {{will never be executed}}

test/stmt/statements.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,14 +342,17 @@ func test_defer(_ a : Int) {
342342

343343
// Not ok.
344344
while false { defer { break } } // expected-error {{'break' cannot transfer control out of a defer statement}}
345+
// expected-warning@-1 {{'defer' at the end of its scope is redundant and will execute immediately}}{{17-22=do}}
345346
defer { return } // expected-error {{'return' cannot transfer control out of a defer statement}}
347+
// expected-warning@-1 {{'defer' at the end of its scope is redundant and will execute immediately}}{{3-8=do}}
346348
}
347349

348350
class SomeTestClass {
349351
var x = 42
350352

351353
func method() {
352354
defer { x = 97 } // self. not required here!
355+
// expected-warning@-1 {{'defer' at the end of its scope is redundant and will execute immediately}}{{5-10=do}}
353356
}
354357
}
355358

0 commit comments

Comments
 (0)