2012-02-16 21:50:37 -07:00
|
|
|
// errorcheck
|
2011-03-15 12:05:37 -06:00
|
|
|
|
2016-04-10 15:32:26 -06:00
|
|
|
// Copyright 2011 The Go Authors. All rights reserved.
|
2011-03-15 12:05:37 -06:00
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2012-02-23 00:47:26 -07:00
|
|
|
// Verify that erroneous labels are caught by the compiler.
|
|
|
|
// This set is caught by pass 1.
|
|
|
|
// Does not compile.
|
2011-03-15 12:05:37 -06:00
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
var x int
|
|
|
|
|
|
|
|
func f() {
|
2011-03-25 11:36:46 -06:00
|
|
|
L1: // ERROR "label .*L1.* defined and not used"
|
2011-03-15 12:05:37 -06:00
|
|
|
for {
|
|
|
|
}
|
2011-03-25 11:36:46 -06:00
|
|
|
L2: // ERROR "label .*L2.* defined and not used"
|
2015-07-20 14:00:28 -06:00
|
|
|
select {}
|
2011-03-25 11:36:46 -06:00
|
|
|
L3: // ERROR "label .*L3.* defined and not used"
|
2011-03-15 12:05:37 -06:00
|
|
|
switch {
|
|
|
|
}
|
2011-03-25 11:36:46 -06:00
|
|
|
L4: // ERROR "label .*L4.* defined and not used"
|
2011-03-15 12:05:37 -06:00
|
|
|
if true {
|
|
|
|
}
|
2011-03-25 11:36:46 -06:00
|
|
|
L5: // ERROR "label .*L5.* defined and not used"
|
2011-03-15 12:05:37 -06:00
|
|
|
f()
|
2011-03-25 11:36:46 -06:00
|
|
|
L6: // GCCGO_ERROR "previous"
|
2011-03-15 12:05:37 -06:00
|
|
|
f()
|
2011-03-25 11:36:46 -06:00
|
|
|
L6: // ERROR "label .*L6.* already defined"
|
2011-03-15 12:05:37 -06:00
|
|
|
f()
|
|
|
|
if x == 20 {
|
|
|
|
goto L6
|
|
|
|
}
|
|
|
|
|
|
|
|
L7:
|
|
|
|
for {
|
|
|
|
break L7
|
|
|
|
}
|
|
|
|
|
|
|
|
L8:
|
|
|
|
for {
|
|
|
|
if x == 21 {
|
|
|
|
continue L8
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
L9:
|
|
|
|
switch {
|
|
|
|
case true:
|
|
|
|
break L9
|
2011-03-25 11:36:46 -06:00
|
|
|
defalt: // ERROR "label .*defalt.* defined and not used"
|
2011-03-15 12:05:37 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
L10:
|
|
|
|
select {
|
|
|
|
default:
|
|
|
|
break L10
|
|
|
|
}
|
2015-07-20 16:39:14 -06:00
|
|
|
|
|
|
|
goto L10
|
|
|
|
|
|
|
|
goto go2 // ERROR "label go2 not defined"
|
2011-03-15 12:05:37 -06:00
|
|
|
}
|