1
0
mirror of https://github.com/golang/go synced 2024-11-06 00:26:11 -07:00
go/test/fixedbugs/issue15838.dir/a.go
Robert Griesemer 30282b091d cmd/compile: correctly import labels, gotos, and fallthroughs
The importer had several bugs with respect to labels and gotos:
- it didn't create a new ONAME node for label names (label dcl,
  goto, continue, and break)
- it overwrote the symbol for gotos with the dclstack
- it didn't set the dclstack for labels

In the process changed export format slightly to always assume
a label name for labels and gotos, and never assume a label for
fallthroughs.

For fallthroughs and switch cases, now also set Xoffset like in
the parser. (Not setting it, i.e., using 0 was ok since this is
only used for verifying correct use of fallthroughs, which was
checked already. But it's an extra level of verification of the
import.)

Fixes #15838.

Change-Id: I3637f6314b8651c918df0c8cd70cd858c92bd483
Reviewed-on: https://go-review.googlesource.com/23445
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-05-26 00:32:03 +00:00

62 lines
541 B
Go

// Copyright 2016 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.
package a
func F1() {
L:
goto L
}
func F2() {
L:
for {
break L
}
}
func F3() {
L:
for {
continue L
}
}
func F4() {
switch {
case true:
fallthrough
default:
}
}
type T struct{}
func (T) M1() {
L:
goto L
}
func (T) M2() {
L:
for {
break L
}
}
func (T) M3() {
L:
for {
continue L
}
}
func (T) M4() {
switch {
case true:
fallthrough
default:
}
}