File tree Expand file tree Collapse file tree 3 files changed +48
-1
lines changed
branches/swift-5.1-old-llvm-branch Expand file tree Collapse file tree 3 files changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -1241,7 +1241,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-01-24-a: b6f62823aa5010b2ae53f15f72a57
1241
1241
refs/heads/marcrasi-astverifier-disable: 3fac766a23a77ebd0640296bfd7fc116ea60a4e0
1242
1242
refs/heads/revert-22227-a-tall-white-fountain-played: adfce60b2eaa54903ea189bed8a783bca609fa53
1243
1243
refs/heads/revert-22300-revert-22227-a-tall-white-fountain-played: 5f92040224df7dd4e618fdfb367349df64d8acad
1244
- refs/heads/swift-5.1-old-llvm-branch: 7b0d10e2c762c5e3d4fb1ca1bef969db8a1cc536
1244
+ refs/heads/swift-5.1-old-llvm-branch: 003850fb0d886493305f7f7a0b23dbadc2bbfd07
1245
1245
refs/heads/swift-5.1-branch: 8060872acb4105d9655e020fe047e1ebcd77d0fb
1246
1246
refs/tags/swift-4.2.2-RELEASE: e429d1f1aaf59e69d38207a96e56265c7f6fccec
1247
1247
refs/tags/swift-5.0-DEVELOPMENT-SNAPSHOT-2019-02-02-a: 3e5a03d32ff3b1e9af90d6c1198c14f938379a6e
Original file line number Diff line number Diff line change @@ -92,6 +92,18 @@ bool Parser::isStartOfStmt() {
92
92
// putting a label on something inappropriate in parseStmt().
93
93
return isStartOfStmt ();
94
94
}
95
+
96
+ case tok::at_sign: {
97
+ // Might be a statement or case attribute. The only one of these we have
98
+ // right now is `@unknown default`, so hardcode a check for an attribute
99
+ // without any parens.
100
+ if (!peekToken ().is (tok::identifier))
101
+ return false ;
102
+ Parser::BacktrackingScope backtrack (*this );
103
+ consumeToken (tok::at_sign);
104
+ consumeToken (tok::identifier);
105
+ return isStartOfStmt ();
106
+ }
95
107
}
96
108
}
97
109
Original file line number Diff line number Diff line change @@ -609,3 +609,38 @@ switch x {
609
609
@unknown default : // expected-error {{additional 'case' blocks cannot appear after the 'default' block of a 'switch'}}
610
610
break
611
611
}
612
+
613
+ func testReturnBeforeUnknownDefault( ) {
614
+ switch x { // expected-error {{switch must be exhaustive}}
615
+ case 1 :
616
+ return
617
+ @unknown default : // expected-note {{remove '@unknown' to handle remaining values}}
618
+ break
619
+ }
620
+ }
621
+
622
+ func testReturnBeforeIncompleteUnknownDefault( ) {
623
+ switch x { // expected-error {{switch must be exhaustive}}
624
+ case 1 :
625
+ return
626
+ @unknown default // expected-error {{expected ':' after 'default'}}
627
+ // expected-note@-1 {{remove '@unknown' to handle remaining values}}
628
+ }
629
+ }
630
+
631
+ func testReturnBeforeIncompleteUnknownDefault2( ) {
632
+ switch x { // expected-error {{switch must be exhaustive}} expected-note {{do you want to add a default clause?}}
633
+ case 1 :
634
+ return
635
+ @unknown // expected-error {{unknown attribute 'unknown'}}
636
+ } // expected-error {{expected declaration}}
637
+ }
638
+
639
+ func testIncompleteArrayLiteral( ) {
640
+ switch x { // expected-error {{switch must be exhaustive}}
641
+ case 1 :
642
+ _ = [ 1 // expected-error {{expected ']' in container literal expression}} expected-note {{to match this opening '['}}
643
+ @unknown default : // expected-note {{remove '@unknown' to handle remaining values}}
644
+ ( )
645
+ }
646
+ }
You can’t perform that action at this time.
0 commit comments