mirror of https://github.com/golang/go.git
cmd/compile: use fake package for allocating autos
Make sure auto names don't conflict with function names. Before this CL, we confused name a.len (the len field of the slice a) with a.len (the function len declared on a). Fixes #15961 Change-Id: I14913de697b521fb35db9a1b10ba201f25d552bb Reviewed-on: https://go-review.googlesource.com/23789 Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
27c5dcffef
commit
2f088884ae
|
|
@ -156,6 +156,8 @@ var Debug_typeassert int
|
|||
|
||||
var localpkg *Pkg // package being compiled
|
||||
|
||||
var autopkg *Pkg // fake package for allocating auto variables
|
||||
|
||||
var importpkg *Pkg // package being imported
|
||||
|
||||
var itabpkg *Pkg // fake pkg for itab entries
|
||||
|
|
|
|||
|
|
@ -108,6 +108,8 @@ func Main() {
|
|||
|
||||
localpkg = mkpkg("")
|
||||
localpkg.Prefix = "\"\""
|
||||
autopkg = mkpkg("")
|
||||
autopkg.Prefix = "\"\""
|
||||
|
||||
// pseudo-package, for scoping
|
||||
builtinpkg = mkpkg("go.builtin")
|
||||
|
|
|
|||
|
|
@ -4378,7 +4378,7 @@ func (e *ssaExport) SplitStruct(name ssa.LocalSlot, i int) ssa.LocalSlot {
|
|||
// namedAuto returns a new AUTO variable with the given name and type.
|
||||
func (e *ssaExport) namedAuto(name string, typ ssa.Type) ssa.GCNode {
|
||||
t := typ.(*Type)
|
||||
s := Lookup(name)
|
||||
s := &Sym{Name: name, Pkg: autopkg}
|
||||
n := Nod(ONAME, nil, nil)
|
||||
s.Def = n
|
||||
s.Def.Used = true
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
// compile
|
||||
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package y
|
||||
|
||||
type symSet []int
|
||||
|
||||
//go:noinline
|
||||
func (s symSet) len() (r int) {
|
||||
return 0
|
||||
}
|
||||
|
||||
func f(m map[int]symSet) {
|
||||
var symSet []int
|
||||
for _, x := range symSet {
|
||||
m[x] = nil
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue