File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -326,6 +326,11 @@ void StmtEmitter::visitBraceStmt(BraceStmt *S) {
326
326
// Ignore all other implicit expressions.
327
327
continue ;
328
328
}
329
+ } else if (auto D = ESD.dyn_cast <Decl*>()) {
330
+ // Local type declarations are not unreachable because they can appear
331
+ // after the declared type has already been used.
332
+ if (isa<TypeDecl>(D))
333
+ continue ;
329
334
}
330
335
331
336
if (StmtType != UnknownStmtType) {
Original file line number Diff line number Diff line change 4
4
func function1( ) {
5
5
return
6
6
7
- class UnreachableClass { } // expected-warning {{code after 'return' will never be executed} }
7
+ class LocalClass { }
8
8
}
9
9
10
10
func function2( ) {
@@ -19,4 +19,4 @@ func function2() {
19
19
20
20
// CHECK-LABEL: sil private [transparent] [ossa] @$s11local_types9function2yyFyycfU_1SL_V1xSivpfi : $@convention(thin) () -> Int
21
21
22
- // CHECK-LABEL: sil_vtable UnreachableClass
22
+ // CHECK-LABEL: sil_vtable LocalClass
Original file line number Diff line number Diff line change 1
- // RUN: %target-swift-emit-sil %s -o /dev/null -verify
1
+ // RUN: %target-swift-emit-sil %s -verify | %FileCheck %s
2
2
3
3
func testUnreachableAfterReturn( ) -> Int {
4
4
var x : Int = 3
@@ -146,3 +146,12 @@ func testUnreachableCatchClause() {
146
146
print ( " some error " )
147
147
}
148
148
}
149
+
150
+ func sr13639( ) -> Int {
151
+ return Foo . bar
152
+ struct Foo { // no-warning
153
+ static var bar = 0
154
+ // CHECK: sil private @$s16unreachable_code7sr13639SiyF3FooL_V7fooFuncyyF : $@convention(method) (Foo) -> ()
155
+ func fooFunc( ) { }
156
+ }
157
+ }
You can’t perform that action at this time.
0 commit comments