Debian Codegraph @

test/label.go

raw
1 // errorcheck
2
3 // Copyright 2011 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 // Verify that erroneous labels are caught by the compiler.
8 // This set is caught by pass 1.
9 // Does not compile.
10
11 package main
12
13 var x int
14
15 func f() {
16 L1: // ERROR "label .*L1.* defined and not used"
17 for {
18 }
19 L2: // ERROR "label .*L2.* defined and not used"
20 select {}
21 L3: // ERROR "label .*L3.* defined and not used"
22 switch {
23 }
24 L4: // ERROR "label .*L4.* defined and not used"
25 if true {
26 }
27 L5: // ERROR "label .*L5.* defined and not used"
28 f()
29 L6: // GCCGO_ERROR "previous"
30 f()
31 L6: // ERROR "label .*L6.* already defined"
32 f()
33 if x == 20 {
34 goto L6
35 }
36
37 L7:
38 for {
39 break L7
40 }
41
42 L8:
43 for {
44 if x == 21 {
45 continue L8
46 }
47 }
48
49 L9:
50 switch {
51 case true:
52 break L9
53 defalt: // ERROR "label .*defalt.* defined and not used"
54 }
55
56 L10:
57 select {
58 default:
59 break L10
60 }
61
62 goto L10
63
64 goto go2 // ERROR "label go2 not defined|reference to undefined label .*go2"
65 }