Colin Cross | 7bb052a | 2015-02-03 12:59:37 -0800 | [diff] [blame] | 1 | // errorcheck |
| 2 | |
| 3 | // Copyright 2010 The Go Authors. All rights reserved. |
| 4 | // Use of this source code is governed by a BSD-style |
| 5 | // license that can be found in the LICENSE file. |
| 6 | |
| 7 | // 6g accepts the program below even though it is syntactically incorrect: |
| 8 | // Each statement in the list of statements for each case clause must be |
| 9 | // terminated with a semicolon. No semicolon is present for the labeled |
| 10 | // statements and because the last token is a colon ":", no semicolon is |
| 11 | // inserted automatically. |
| 12 | // |
| 13 | // Both gccgo and gofmt correctly refuse this program as is and accept it |
| 14 | // when the semicolons are present. |
| 15 | |
Dan Willemsen | 6ff2325 | 2015-09-15 13:49:18 -0700 | [diff] [blame] | 16 | // This is a test case for issue 777 ( https://golang.org/issue/777 ). |
Colin Cross | 7bb052a | 2015-02-03 12:59:37 -0800 | [diff] [blame] | 17 | |
| 18 | package main |
| 19 | |
| 20 | func main() { |
| 21 | switch 0 { |
| 22 | case 0: |
| 23 | L0: // ERROR "statement" |
| 24 | case 1: |
| 25 | L1: // ERROR "statement" |
| 26 | default: |
| 27 | // correct since no semicolon is required before a '}' |
| 28 | goto L2 |
| 29 | L2: |
| 30 | } |
| 31 | } |