1
0
mirror of https://github.com/golang/go synced 2024-09-29 17:14:29 -06:00

cmd/vet/internal/cfg: don't crash on malformed goto statement

Change-Id: Ib285c02e240f02e9d5511bd448163ec1d4e75516
Reviewed-on: https://go-review.googlesource.com/24323
Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
Alan Donovan 2016-06-22 10:41:30 -04:00
parent f2c13d713d
commit 4764d6fd6e
2 changed files with 9 additions and 1 deletions

View File

@ -98,7 +98,9 @@ start:
}
case token.GOTO:
block = b.labeledBlock(s.Label)._goto
if s.Label != nil {
block = b.labeledBlock(s.Label)._goto
}
}
if block == nil {
block = b.newBlock("undefined.branch")

View File

@ -122,6 +122,12 @@ func f10(ch chan int) {
}
live()
}
func f11() {
goto; // mustn't crash
dead()
}
`
func TestDeadCode(t *testing.T) {