]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: use yyerrorl(n.Pos, ...) in typecheckdef
authorYury Smolsky <yury@smolsky.by>
Mon, 28 May 2018 14:15:11 +0000 (17:15 +0300)
committerRobert Griesemer <gri@golang.org>
Tue, 11 Sep 2018 17:53:53 +0000 (17:53 +0000)
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: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/gc/typecheck.go

index bb78d8bf73d8d303c478b9d059273ee867956a1c..c2b84541852b5afabd3182e9f4c68acb95c9455e 100644 (file)
@@ -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
                        }