]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/gc: correctly use internal call to error reporting
authorRobert Griesemer <gri@golang.org>
Mon, 16 Nov 2015 19:24:43 +0000 (11:24 -0800)
committerRobert Griesemer <gri@golang.org>
Tue, 17 Nov 2015 01:05:07 +0000 (01:05 +0000)
Fixes #13266.

Change-Id: I31da922e0599989e52acf346374c2077b157ebb7
Reviewed-on: https://go-review.googlesource.com/16971
Reviewed-by: Chris Manghane <cmang@golang.org>
src/cmd/compile/internal/gc/parser.go
test/fixedbugs/issue13266.go [new file with mode: 0644]

index c8a682680d65bc70e1bf88553919e1a832b8a497..d2b382fdfc41bb3f8eb2872a071a3e51ee8c720e 100644 (file)
@@ -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
        }
 
@@ -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.
@@ -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)
        }
diff --git a/test/fixedbugs/issue13266.go b/test/fixedbugs/issue13266.go
new file mode 100644 (file)
index 0000000..3c4f74b
--- /dev/null
@@ -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 %"