@@ -820,7 +820,7 @@ func returnBranches6() -> Int {
820820 case true :
821821 print ( " hello " )
822822 0 // expected-warning {{integer literal is unused}}
823- // expected-error@-1 {{non-expression branch of 'switch' expression may only end with a 'throw'}}
823+ // expected-error@-1 {{non-expression branch of 'switch' expression may only end with a 'throw' or 'fallthrough' }}
824824 case false :
825825 1
826826 }
@@ -835,7 +835,7 @@ func returnBranches6PoundIf() -> Int {
835835 print ( " hello " )
836836 0 // expected-warning {{integer literal is unused}}
837837 #endif
838- // expected-error@-1 {{non-expression branch of 'switch' expression may only end with a 'throw'}}
838+ // expected-error@-1 {{non-expression branch of 'switch' expression may only end with a 'throw' or 'fallthrough' }}
839839 case false :
840840 1
841841 }
@@ -850,7 +850,7 @@ func returnBranches6PoundIf2() -> Int {
850850 print ( " hello " )
851851 0
852852 #endif
853- // expected-error@-1 {{non-expression branch of 'switch' expression may only end with a 'throw'}}
853+ // expected-error@-1 {{non-expression branch of 'switch' expression may only end with a 'throw' or 'fallthrough' }}
854854 case false :
855855 1
856856 }
@@ -882,7 +882,7 @@ func returnBranches9() -> Int {
882882 let i = switch Bool . random ( ) {
883883 case true :
884884 print ( " hello " )
885- if . random( ) { } // expected-error {{non-expression branch of 'switch' expression may only end with a 'throw'}}
885+ if . random( ) { } // expected-error {{non-expression branch of 'switch' expression may only end with a 'throw' or 'fallthrough' }}
886886 case false :
887887 1
888888 }
@@ -898,7 +898,7 @@ func returnBranches10() -> Int {
898898 0 // expected-warning {{integer literal is unused}}
899899 case false :
900900 2 // expected-warning {{integer literal is unused}}
901- } // expected-error {{non-expression branch of 'switch' expression may only end with a 'throw'}}
901+ } // expected-error {{non-expression branch of 'switch' expression may only end with a 'throw' or 'fallthrough' }}
902902 case false :
903903 1
904904 }
@@ -914,7 +914,7 @@ func returnBranches11() -> Int {
914914 " " // expected-warning {{string literal is unused}}
915915 case false :
916916 2 // expected-warning {{integer literal is unused}}
917- } // expected-error {{non-expression branch of 'switch' expression may only end with a 'throw'}}
917+ } // expected-error {{non-expression branch of 'switch' expression may only end with a 'throw' or 'fallthrough' }}
918918 case false :
919919 1
920920 }
@@ -1059,7 +1059,7 @@ func testPoundIfBranch3() -> Int {
10591059 #if false
10601060 0
10611061 #endif
1062- // expected-error@-1 {{non-expression branch of 'switch' expression may only end with a 'throw'}}
1062+ // expected-error@-1 {{non-expression branch of 'switch' expression may only end with a 'throw' or 'fallthrough' }}
10631063 case false :
10641064 0
10651065 }
@@ -1100,7 +1100,7 @@ func testPoundIfBranch6() -> Int {
11001100 0
11011101 #endif
11021102 0 // expected-warning {{integer literal is unused}}
1103- // expected-error@-1 {{non-expression branch of 'switch' expression may only end with a 'throw'}}
1103+ // expected-error@-1 {{non-expression branch of 'switch' expression may only end with a 'throw' or 'fallthrough' }}
11041104 case false :
11051105 1
11061106 }
@@ -1180,6 +1180,38 @@ func fallthrough2() -> Int {
11801180 return x
11811181}
11821182
1183+ func fallthrough3( ) -> Int {
1184+ let x = switch true {
1185+ case true :
1186+ fallthrough
1187+ case false :
1188+ 0
1189+ }
1190+ return x
1191+ }
1192+
1193+ func fallthrough4( ) -> Int {
1194+ let x = switch true {
1195+ case true :
1196+ fallthrough
1197+ return 0 // expected-error {{cannot use 'return' to transfer control out of 'switch' expression}}
1198+ case false :
1199+ 0
1200+ }
1201+ return x
1202+ }
1203+
1204+ func fallthrough5( ) -> Int {
1205+ let x = switch true {
1206+ case true :
1207+ fallthrough
1208+ print ( 0 ) // expected-error {{non-expression branch of 'switch' expression may only end with a 'throw' or 'fallthrough'}}
1209+ case false :
1210+ 0
1211+ }
1212+ return x
1213+ }
1214+
11831215func breakAfterNeverExpr( ) -> String {
11841216 // We avoid turning this into a switch expression because of the 'break'.
11851217 switch Bool . random ( ) {
0 commit comments