Skip to content

Commit

Permalink
[dev.ssa] cmd/compile/internal/gc: handle _ label correctly
Browse files Browse the repository at this point in the history
An empty label statement can just be ignored, as it cannot
be the target of any gotos.

Tests are already in test/fixedbugs/issue7538*.go

Fixes #11589
Fixes #11593

Change-Id: Iadcd639e7200ce16aa40fd7fa3eaf82522513e82
Reviewed-on: https://go-review.googlesource.com/12093
Reviewed-by: Daniel Morsing <[email protected]>
Reviewed-by: Brad Fitzpatrick <[email protected]>
  • Loading branch information
randall77 committed Jul 12, 2015
1 parent 4c521ac commit 7e4c06d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cmd/compile/internal/gc/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ func (s *state) stmt(n *Node) {
s.assign(OAS, n.Left.Name.Heapaddr, palloc)

case OLABEL, OGOTO:
if n.Op == OLABEL && isblanksym(n.Left.Sym) {
// Empty identifier is valid but useless.
// See issues 11589, 11593.
return
}
// get block at label, or make one
t := s.labels[n.Left.Sym.Name]
if t == nil {
Expand Down

0 comments on commit 7e4c06d

Please sign in to comment.