From: Yury Smolsky Date: Mon, 28 May 2018 14:15:11 +0000 (+0300) Subject: cmd/compile: use yyerrorl(n.Pos, ...) in typecheckdef X-Git-Tag: go1.12beta1~1118 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ef7212e2cfc786e5b81a0d3ac55371628177e013;p=gostls13.git 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 TryBot-Result: Gobot Gobot Reviewed-by: Robert Griesemer --- diff --git a/src/cmd/compile/internal/gc/typecheck.go b/src/cmd/compile/internal/gc/typecheck.go index bb78d8bf73..c2b8454185 100644 --- a/src/cmd/compile/internal/gc/typecheck.go +++ b/src/cmd/compile/internal/gc/typecheck.go @@ -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 }