package gc
import (
+ "cmd/compile/internal/syntax"
"cmd/internal/obj"
+ "cmd/internal/src"
"fmt"
"sort"
"strings"
// redeclare emits a diagnostic about symbol s being redeclared somewhere.
func redeclare(s *Sym, where string) {
- if s.Lastlineno == 0 {
+ if !s.Lastlineno.IsKnown() {
var tmp string
if s.Origpkg != nil {
tmp = s.Origpkg.Path
// named OLITERAL needs Name; most OLITERALs don't.
n.Name = new(Name)
}
- n.Lineno = lineno
+ n.Pos = lineno
s := n.Sym
// kludgy: typecheckok means we're past parsing. Eg genwrapper may declare out of package names later.
// declare constants from grammar
// new_name_list [[type] = expr_list]
func constiter(vl []*Node, t *Node, cl []*Node) []*Node {
- lno := int32(0) // default is to leave line number alone in listtreecopy
+ var lno src.XPos // default is to leave line number alone in listtreecopy
if len(cl) == 0 {
if t != nil {
yyerror("const declaration cannot have type without expression")
}
cl = lastconst
t = lasttype
- lno = vl[0].Lineno
+ lno = vl[0].Pos
} else {
lastconst = cl
lasttype = t
continue
}
if !colasname(n) {
- yyerrorl(defn.Lineno, "non-name %v on left side of :=", n)
+ yyerrorl(defn.Pos, "non-name %v on left side of :=", n)
nerr++
continue
}
if n.Sym.Flags&SymUniq == 0 {
- yyerrorl(defn.Lineno, "%v repeated on left side of :=", n.Sym)
+ yyerrorl(defn.Pos, "%v repeated on left side of :=", n.Sym)
n.Diag = true
nerr++
continue
}
if nnew == 0 && nerr == 0 {
- yyerrorl(defn.Lineno, "no new variables on left side of :=")
+ yyerrorl(defn.Pos, "no new variables on left side of :=")
}
}
// node n, which was returned by typedcl0
// is being declared to have uncompiled type t.
// returns the ODCLTYPE node to use.
-func typedcl1(n *Node, t *Node, pragma Pragma, alias bool) *Node {
+func typedcl1(n *Node, t *Node, pragma syntax.Pragma, alias bool) *Node {
if pragma != 0 && alias {
yyerror("cannot specify directive with type alias")
pragma = 0
if t.IsPtr() || t.IsUnsafePtr() {
yyerror("embedded type cannot be a pointer")
- } else if t.Etype == TFORW && t.ForwardType().Embedlineno == 0 {
+ } else if t.Etype == TFORW && !t.ForwardType().Embedlineno.IsKnown() {
t.ForwardType().Embedlineno = lineno
}
}
func structfield(n *Node) *Field {
lno := lineno
- lineno = n.Lineno
+ lineno = n.Pos
if n.Op != ODCLFIELD {
Fatalf("structfield: oops %v\n", n)
continue
}
if seen[f.Sym] {
- lineno = f.Nname.Lineno
+ lineno = f.Nname.Pos
yyerror("duplicate %s %s", what, f.Sym.Name)
continue
}
func interfacefield(n *Node) *Field {
lno := lineno
- lineno = n.Lineno
+ lineno = n.Pos
if n.Op != ODCLFIELD {
Fatalf("interfacefield: oops %v\n", n)
type nowritebarrierrecCall struct {
target *Node
depth int
- lineno int32
+ lineno src.XPos
}
func checknowritebarrierrec() {
visitBottomUp(xtop, func(list []*Node, recursive bool) {
// Functions with write barriers have depth 0.
for _, n := range list {
- if n.Func.WBLineno != 0 && n.Func.Pragma&Yeswritebarrierrec == 0 {
- c.best[n] = nowritebarrierrecCall{target: nil, depth: 0, lineno: n.Func.WBLineno}
+ if n.Func.WBPos.IsKnown() && n.Func.Pragma&Yeswritebarrierrec == 0 {
+ c.best[n] = nowritebarrierrecCall{target: nil, depth: 0, lineno: n.Func.WBPos}
}
}
// yeswritebarrierrec function.
continue
}
- if n.Func.WBLineno == 0 {
+ if !n.Func.WBPos.IsKnown() {
c.curfn = n
c.visitcodelist(n.Nbody)
}
call = c.best[n]
}
err = fmt.Sprintf("write barrier prohibited by caller; %v%s", n.Func.Nname, err)
- yyerrorl(n.Func.WBLineno, err)
+ yyerrorl(n.Func.WBPos, err)
}
})
}
if ok && fnbest.depth+1 >= best.depth {
return
}
- c.best[c.curfn] = nowritebarrierrecCall{target: defn, depth: fnbest.depth + 1, lineno: n.Lineno}
+ c.best[c.curfn] = nowritebarrierrecCall{target: defn, depth: fnbest.depth + 1, lineno: n.Pos}
c.stable = false
}