go.tools/pointer: fix constraint generation bug in *ssa.Select.
The previous code assumed that each channel item contained one field. + regression test. R=crawshaw CC=golang-dev https://golang.org/cl/25480044
This commit is contained in:
parent
775fb1976b
commit
70692d3c5f
|
|
@ -994,7 +994,7 @@ func (a *analysis) genInstr(cgn *cgnode, instr ssa.Instruction) {
|
|||
switch st.Dir {
|
||||
case ast.RECV:
|
||||
a.genLoad(cgn, recv, st.Chan, 0, elemSize)
|
||||
recv++
|
||||
recv += nodeid(elemSize)
|
||||
|
||||
case ast.SEND:
|
||||
a.genStore(cgn, st.Chan, a.valueNode(st.Send), 0, elemSize)
|
||||
|
|
|
|||
|
|
@ -90,9 +90,29 @@ func chan4() {
|
|||
}
|
||||
}
|
||||
|
||||
// Multi-word channel value in select with multiple receive cases.
|
||||
// (Regtest for a crash.)
|
||||
func chan5() {
|
||||
type T struct {
|
||||
x *int
|
||||
y interface{}
|
||||
}
|
||||
ch := make(chan T)
|
||||
ch <- T{new(int), incr} // @line ch5new
|
||||
select {
|
||||
case a := <-ch:
|
||||
print(a.x) // @pointsto new@ch5new:13
|
||||
print(a.y) // @types func(x int) int
|
||||
case b := <-ch:
|
||||
print(b.x) // @pointsto new@ch5new:13
|
||||
print(b.y) // @types func(x int) int
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
chan1()
|
||||
chan2()
|
||||
chan3()
|
||||
chan4()
|
||||
chan5()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue