Skip to content

Commit

Permalink
cmd/compile/internal/gc: correctly use internal call to error reporting
Browse files Browse the repository at this point in the history
Fixes #13266.

Change-Id: I31da922e0599989e52acf346374c2077b157ebb7
Reviewed-on: https://go-review.googlesource.com/16971
Reviewed-by: Chris Manghane <[email protected]>
  • Loading branch information
griesemer committed Nov 17, 2015
1 parent f9357cd commit a20556b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/cmd/compile/internal/gc/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (p *parser) syntax_error(msg string) {
msg = ", " + msg
default:
// plain error - we don't care about current token
Yyerror("syntax error: " + msg)
Yyerror("syntax error: %s", msg)
return
}

Expand All @@ -138,7 +138,7 @@ func (p *parser) syntax_error(msg string) {
tok = tokstring(p.tok)
}

Yyerror("syntax error: unexpected " + tok + msg)
Yyerror("syntax error: unexpected %s", tok + msg)
}

// Advance consumes tokens until it finds a token of the stoplist.
Expand Down Expand Up @@ -1669,7 +1669,7 @@ func (p *parser) sym() *Sym {
return nil

default:
p.syntax_error("")
p.syntax_error("expecting name")
p.advance()
return new(Sym)
}
Expand Down
10 changes: 10 additions & 0 deletions test/fixedbugs/issue13266.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// errorcheck

// Copyright 2015 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.

// Offending character % must not be interpreted as
// start of format verb when emitting error message.

package% // ERROR "unexpected %"

0 comments on commit a20556b

Please sign in to comment.