Commit ef7212e2 authored by Yury Smolsky's avatar Yury Smolsky Committed by Robert Griesemer

cmd/compile: use yyerrorl(n.Pos, ...) in typecheckdef

n.Pos.IsKnown() is not needed because it is performed in setlineno.

toolstash-check passed.

Updates #19683.

Change-Id: I34d6a0e6dc9970679d99e8f3424f289ebf1e86ba
Reviewed-on: https://go-review.googlesource.com/114915
Run-TryBot: Yury Smolsky <yury@smolsky.by>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
parent aa4fc0e7
......@@ -3640,25 +3640,22 @@ func typecheckdeftype(n *Node) {
}
func typecheckdef(n *Node) {
lno := lineno
setlineno(n)
lno := setlineno(n)
if n.Op == ONONAME {
if !n.Diag() {
n.SetDiag(true)
if n.Pos.IsKnown() {
lineno = n.Pos
}
// Note: adderrorname looks for this string and
// adds context about the outer expression
yyerror("undefined: %v", n.Sym)
yyerrorl(lineno, "undefined: %v", n.Sym)
}
lineno = lno
return
}
if n.Walkdef() == 1 {
lineno = lno
return
}
......@@ -3701,20 +3698,19 @@ func typecheckdef(n *Node) {
e := n.Name.Defn
n.Name.Defn = nil
if e == nil {
lineno = n.Pos
Dump("typecheckdef nil defn", n)
yyerror("xxx")
yyerrorl(n.Pos, "xxx")
}
e = typecheck(e, Erv)
if Isconst(e, CTNIL) {
yyerror("const initializer cannot be nil")
yyerrorl(n.Pos, "const initializer cannot be nil")
goto ret
}
if e.Type != nil && e.Op != OLITERAL || !e.isGoConst() {
if !e.Diag() {
yyerror("const initializer %v is not a constant", e)
yyerrorl(n.Pos, "const initializer %v is not a constant", e)
e.SetDiag(true)
}
......@@ -3724,12 +3720,12 @@ func typecheckdef(n *Node) {
t := n.Type
if t != nil {
if !okforconst[t.Etype] {
yyerror("invalid constant type %v", t)
yyerrorl(n.Pos, "invalid constant type %v", t)
goto ret
}
if !e.Type.IsUntyped() && !eqtype(t, e.Type) {
yyerror("cannot use %L as type %v in const initializer", e, t)
yyerrorl(n.Pos, "cannot use %L as type %v in const initializer", e, t)
goto ret
}
......
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