Skip to content

Commit a20556b

Browse files
committed
cmd/compile/internal/gc: correctly use internal call to error reporting
Fixes #13266. Change-Id: I31da922e0599989e52acf346374c2077b157ebb7 Reviewed-on: https://go-review.googlesource.com/16971 Reviewed-by: Chris Manghane <[email protected]>
1 parent f9357cd commit a20556b

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/cmd/compile/internal/gc/parser.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func (p *parser) syntax_error(msg string) {
116116
msg = ", " + msg
117117
default:
118118
// plain error - we don't care about current token
119-
Yyerror("syntax error: " + msg)
119+
Yyerror("syntax error: %s", msg)
120120
return
121121
}
122122

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

141-
Yyerror("syntax error: unexpected " + tok + msg)
141+
Yyerror("syntax error: unexpected %s", tok + msg)
142142
}
143143

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

16711671
default:
1672-
p.syntax_error("")
1672+
p.syntax_error("expecting name")
16731673
p.advance()
16741674
return new(Sym)
16751675
}

test/fixedbugs/issue13266.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// errorcheck
2+
3+
// Copyright 2015 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
// Offending character % must not be interpreted as
8+
// start of format verb when emitting error message.
9+
10+
package% // ERROR "unexpected %"

0 commit comments

Comments
 (0)