mirror of
https://github.com/golang/go
synced 2024-09-04 23:44:16 +00:00
cmd/gc: ignore blank (_) labels in label declarations
Fixes #7538 LGTM=rsc R=gri, rsc CC=golang-codereviews https://golang.org/cl/85040045
This commit is contained in:
parent
51fba7d8f5
commit
907736e2fe
|
@ -301,6 +301,10 @@ gen(Node *n)
|
|||
break;
|
||||
|
||||
case OLABEL:
|
||||
if(isblanksym(n->left->sym)) {
|
||||
break;
|
||||
}
|
||||
|
||||
lab = newlab(n);
|
||||
|
||||
// if there are pending gotos, resolve them all to the current pc.
|
||||
|
|
15
test/fixedbugs/issue7538a.go
Normal file
15
test/fixedbugs/issue7538a.go
Normal file
|
@ -0,0 +1,15 @@
|
|||
// errorcheck
|
||||
|
||||
// Copyright 2014 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Issue 7538: blank (_) labels handled incorrectly
|
||||
|
||||
package p
|
||||
|
||||
func f() {
|
||||
_:
|
||||
_:
|
||||
goto _ // ERROR "not defined"
|
||||
}
|
13
test/fixedbugs/issue7538b.go
Normal file
13
test/fixedbugs/issue7538b.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
// compile
|
||||
|
||||
// Copyright 2014 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Issue 7538: blank (_) labels handled incorrectly
|
||||
|
||||
package p
|
||||
|
||||
func f() {
|
||||
_:
|
||||
}
|
Loading…
Reference in a new issue