]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: ignore blank (_) labels in label declarations
authorJan Ziak <0xe2.0x9a.0x9b@gmail.com>
Wed, 9 Apr 2014 06:34:17 +0000 (08:34 +0200)
committerJan Ziak <0xe2.0x9a.0x9b@gmail.com>
Wed, 9 Apr 2014 06:34:17 +0000 (08:34 +0200)
Fixes #7538

LGTM=rsc
R=gri, rsc
CC=golang-codereviews
https://golang.org/cl/85040045

src/cmd/gc/gen.c
test/fixedbugs/issue7538a.go [new file with mode: 0644]
test/fixedbugs/issue7538b.go [new file with mode: 0644]

index b7cc6217929d6514275b7bcf6b34a338f4b7de41..5a5c1c24c1ab07f415773f1ff977c2940b349d6d 100644 (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.
diff --git a/test/fixedbugs/issue7538a.go b/test/fixedbugs/issue7538a.go
new file mode 100644 (file)
index 0000000..283d9eb
--- /dev/null
@@ -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"
+}
diff --git a/test/fixedbugs/issue7538b.go b/test/fixedbugs/issue7538b.go
new file mode 100644 (file)
index 0000000..28cef5d
--- /dev/null
@@ -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() {
+_:
+}