go.tools/go/ssa: fix range iteration over values of pointer to named array type
LGTM=adonovan R=adonovan CC=golang-codereviews https://golang.org/cl/107800045
This commit is contained in:
parent
83c1b4e7d4
commit
afea1b1755
|
@ -1641,7 +1641,7 @@ func (b *builder) rangeIndexed(fn *Function, x Value, tv types.Type) (k, v Value
|
|||
X: x,
|
||||
Index: k,
|
||||
}
|
||||
instr.setType(types.NewPointer(t.Elem().(*types.Array).Elem()))
|
||||
instr.setType(types.NewPointer(t.Elem().Underlying().(*types.Array).Elem()))
|
||||
v = emitLoad(fn, fn.emit(instr))
|
||||
|
||||
case *types.Slice:
|
||||
|
|
|
@ -642,3 +642,16 @@ func bug7840() bool {
|
|||
// This creates a single-predecessor block with a φ-node.
|
||||
return false && a == 0 && a == 0
|
||||
}
|
||||
|
||||
// Regression test for range of pointer to named array type.
|
||||
func init() {
|
||||
type intarr [3]int
|
||||
ia := intarr{1, 2, 3}
|
||||
var count int
|
||||
for _, x := range &ia {
|
||||
count += x
|
||||
}
|
||||
if count != 6 {
|
||||
panic(count)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue