Skip to content

Commit 705a684

Browse files
authored
Merge pull request swiftlang#38581 from CodaFi/locavore
2 parents 5b688bd + 2c936fb commit 705a684

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/SILGen/SILGenStmt.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,10 @@ void StmtEmitter::visitBraceStmt(BraceStmt *S) {
330330
continue;
331331
}
332332
} else if (auto D = ESD.dyn_cast<Decl*>()) {
333-
// Local type declarations are not unreachable because they can appear
334-
// after the declared type has already been used.
335-
if (isa<TypeDecl>(D))
333+
// Local declarations aren't unreachable - only their usages can be. To
334+
// that end, we only care about pattern bindings since their
335+
// initializer expressions can be unreachable.
336+
if (!isa<PatternBindingDecl>(D))
336337
continue;
337338
}
338339

test/SILGen/unreachable_code.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,5 @@ func sr13639() -> Int {
154154
// CHECK: sil private @$s16unreachable_code7sr13639SiyF3FooL_V7fooFuncyyF : $@convention(method) (Foo) -> ()
155155
func fooFunc() {}
156156
}
157+
func appendix() {} // no-warning
157158
}

0 commit comments

Comments
 (0)