From: Robert Griesemer Date: Tue, 18 Apr 2017 22:21:02 +0000 (-0700) Subject: cmd/compile: remove uses of types.Dclstack - not needed anymore X-Git-Tag: go1.9beta1~630 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=48163968b2927247213fca7a6f4678d3c93855dc;p=gostls13.git cmd/compile: remove uses of types.Dclstack - not needed anymore Follow-up on https://go-review.googlesource.com/#/c/39998/. Change-Id: I8830eebd7ea7e02b7edda99e67b6d43529401201 Reviewed-on: https://go-review.googlesource.com/40974 Reviewed-by: Matthew Dempsky --- diff --git a/src/cmd/compile/internal/gc/bimport.go b/src/cmd/compile/internal/gc/bimport.go index ea9c02dea8..245f421731 100644 --- a/src/cmd/compile/internal/gc/bimport.go +++ b/src/cmd/compile/internal/gc/bimport.go @@ -1161,9 +1161,7 @@ func (p *importer) node() *Node { // unreachable - not emitted by exporter case OGOTO, OLABEL: - n := nodl(p.pos(), op, newname(p.expr().Sym), nil) - n.Sym = types.Dclstack // context, for goto restrictions - return n + return nodl(p.pos(), op, newname(p.expr().Sym), nil) case OEND: return nil diff --git a/src/cmd/compile/internal/gc/noder.go b/src/cmd/compile/internal/gc/noder.go index 27c842150b..f0c501b155 100644 --- a/src/cmd/compile/internal/gc/noder.go +++ b/src/cmd/compile/internal/gc/noder.go @@ -725,9 +725,6 @@ func (p *noder) stmt(stmt syntax.Stmt) *Node { if stmt.Label != nil { n.Left = p.newname(stmt.Label) } - if op == OGOTO { - n.Sym = types.Dclstack // context, for goto restriction - } if op == OXFALL { n.Xoffset = int64(types.Block) } @@ -909,7 +906,6 @@ func (p *noder) commClauses(clauses []*syntax.CommClause) []*Node { func (p *noder) labeledStmt(label *syntax.LabeledStmt) *Node { lhs := p.nod(label, OLABEL, p.newname(label.Label), nil) - lhs.Sym = types.Dclstack // context, for goto restriction var ls *Node if label.Stmt != nil { // TODO(mdempsky): Should always be present. diff --git a/src/cmd/compile/internal/types/scope.go b/src/cmd/compile/internal/types/scope.go index 9ee3f796f7..67de273f25 100644 --- a/src/cmd/compile/internal/types/scope.go +++ b/src/cmd/compile/internal/types/scope.go @@ -14,19 +14,19 @@ import ( var blockgen int32 = 1 // max block number var Block int32 // current block number -// Dclstack maintains a stack of shadowed symbol declarations so that +// dclstack maintains a stack of shadowed symbol declarations so that // popdcl can restore their declarations when a block scope ends. // The stack is maintained as a linked list, using Sym's Link field. // // In practice, the "stack" actually ends up forming a tree: goto and label -// statements record the current state of Dclstack so that checkgoto can +// statements record the current state of dclstack so that checkgoto can // validate that a goto statement does not jump over any declarations or // into a new block scope. // // Finally, the Syms in this list are not "real" Syms as they don't actually // represent object names. Sym is just a convenient type for saving shadowed // Sym definitions, and only a subset of its fields are actually used. -var Dclstack *Sym +var dclstack *Sym func dcopy(a, b *Sym) { a.Pkg = b.Pkg @@ -39,8 +39,8 @@ func dcopy(a, b *Sym) { func push(pos src.XPos) *Sym { d := new(Sym) d.Lastlineno = pos - d.Link = Dclstack - Dclstack = d + d.Link = dclstack + dclstack = d return d } @@ -54,7 +54,7 @@ func Pushdcl(s *Sym, pos src.XPos) { // Popdcl pops the innermost block scope and restores all symbol declarations // to their previous state. func Popdcl() { - d := Dclstack + d := dclstack for ; d != nil && d.Name != ""; d = d.Link { s := d.Pkg.Lookup(d.Name) lno := s.Lastlineno @@ -66,7 +66,7 @@ func Popdcl() { Fatalf("popdcl: no mark") } - Dclstack = d.Link // pop mark + dclstack = d.Link // pop mark Block = d.Block } @@ -83,7 +83,7 @@ func Markdcl(lineno src.XPos) { // keep around for debugging func DumpDclstack() { i := 0 - for d := Dclstack; d != nil; d = d.Link { + for d := dclstack; d != nil; d = d.Link { fmt.Printf("%6d %p", i, d) if d.Name != "" { fmt.Printf(" '%s' %v\n", d.Name, d.Pkg.Lookup(d.Name)) @@ -95,7 +95,7 @@ func DumpDclstack() { } func IsDclstackValid() bool { - for d := Dclstack; d != nil; d = d.Link { + for d := dclstack; d != nil; d = d.Link { if d.Name == "" { return false }