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:
Jan Ziak 2014-04-09 08:34:17 +02:00
parent 51fba7d8f5
commit 907736e2fe
3 changed files with 32 additions and 0 deletions

View file

@ -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.

View 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"
}

View 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() {
_:
}