cmd/asm: reject foo(SB)(AX) instead of silently treating as foo(SB)

Add test for assembly errors, to verify fix.
Make sure invalid instruction errors are printed just once
(was printing them once per span iteration, so typically twice).

Fixes #13282.

Change-Id: Id5f66f80a80b3bc4832e00084b0a91f1afec7f8f
Reviewed-on: https://go-review.googlesource.com/18858
Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
Russ Cox 2016-01-24 01:33:16 -05:00
parent 544f28a25e
commit 9d6427d899
6 changed files with 135 additions and 7 deletions

View file

@ -54,7 +54,7 @@ func main() {
lexer := lex.NewLexer(flag.Arg(0), ctxt)
parser := asm.NewParser(ctxt, architecture, lexer)
diag := false
ctxt.Diag = func(format string, args ...interface{}) {
ctxt.DiagFunc = func(format string, args ...interface{}) {
diag = true
log.Printf(format, args...)
}