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
11package main
12
13var x int
14
15func f() {
16L1: // ERROR "label .*L1.* defined and not used"
17	for {
18	}
19L2: // ERROR "label .*L2.* defined and not used"
20	select {}
21L3: // ERROR "label .*L3.* defined and not used"
22	switch {
23	}
24L4: // ERROR "label .*L4.* defined and not used"
25	if true {
26	}
27L5: // ERROR "label .*L5.* defined and not used"
28	f()
29L6: // GCCGO_ERROR "previous"
30	f()
31L6: // ERROR "label .*L6.* already defined"
32	f()
33	if x == 20 {
34		goto L6
35	}
36
37L7:
38	for {
39		break L7
40	}
41
42L8:
43	for {
44		if x == 21 {
45			continue L8
46		}
47	}
48
49L9:
50	switch {
51	case true:
52		break L9
53	defalt: // ERROR "label .*defalt.* defined and not used"
54	}
55
56L10:
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}
66