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:
Alan Donovan 2013-11-13 09:13:42 -05:00
parent 775fb1976b
commit 70692d3c5f
2 changed files with 21 additions and 1 deletions

View File

@ -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)

View File

@ -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()
}