[release-branch.go1.3] go.tools/go/pointer: fix crash in constraint generation of ssa.Convert to a named unsafe.Pointer type.

««« CL 106060046 / 2ced0a1d47e3
go.tools/go/pointer: fix crash in constraint generation of ssa.Convert to a named unsafe.Pointer type.

+ test.

Fixes golang/go#8231.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/106060046
»»»

TBR=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/127060043
This commit is contained in:
Andrew Gerrand 2014-08-12 09:24:35 +10:00
parent a89089ae07
commit bd92d52adb
2 changed files with 9 additions and 1 deletions

View File

@ -431,7 +431,7 @@ func (a *analysis) genConv(conv *ssa.Convert, cgn *cgnode) {
case *types.Pointer: case *types.Pointer:
// *T -> unsafe.Pointer? // *T -> unsafe.Pointer?
if tDst == tUnsafePtr { if tDst.Underlying() == tUnsafePtr {
// ignore for now // ignore for now
// a.copy(res, a.valueNode(conv.X), 1) // a.copy(res, a.valueNode(conv.X), 1)
return return

View File

@ -49,9 +49,17 @@ func conv4() {
print(p) // @pointsto convert@c2p:13 print(p) // @pointsto convert@c2p:13
} }
// Regression test for b/8231.
func conv5() {
type P unsafe.Pointer
var i *struct{}
_ = P(i)
}
func main() { func main() {
conv1() conv1()
conv2() conv2()
conv3() conv3()
conv4() conv4()
conv5()
} }