Commit 4764d6fd authored by Alan Donovan's avatar Alan Donovan

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

Change-Id: Ib285c02e240f02e9d5511bd448163ec1d4e75516
Reviewed-on: https://go-review.googlesource.com/24323Reviewed-by: default avatarRob Pike <r@golang.org>
parent f2c13d71
...@@ -98,7 +98,9 @@ start: ...@@ -98,7 +98,9 @@ start:
} }
case token.GOTO: case token.GOTO:
block = b.labeledBlock(s.Label)._goto if s.Label != nil {
block = b.labeledBlock(s.Label)._goto
}
} }
if block == nil { if block == nil {
block = b.newBlock("undefined.branch") block = b.newBlock("undefined.branch")
......
...@@ -122,6 +122,12 @@ func f10(ch chan int) { ...@@ -122,6 +122,12 @@ func f10(ch chan int) {
} }
live() live()
} }
func f11() {
goto; // mustn't crash
dead()
}
` `
func TestDeadCode(t *testing.T) { func TestDeadCode(t *testing.T) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment