cmd/cgo: fix inappropriate array copy

Ensure that during rewriting of expressions that take the address of
an array, that we properly recognize *ast.IndexExpr as an operation
to create a pointer variable and thus assign the proper addressOf
and deference operators as "&" and "*" respectively.

This fixes a regression from CL 142884.

Fixed #32579

Change-Id: I3cb78becff4f8035d66fc5536e5b52857eacaa3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/183458
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
kawakami 2019-06-23 05:30:24 +09:00 committed by Ian Lance Taylor
parent 4ae3835aa2
commit 38fc0afca6
3 changed files with 15 additions and 0 deletions

View file

@ -1256,6 +1256,8 @@ func (p *Package) isVariable(x ast.Expr) bool {
return true
case *ast.SelectorExpr:
return p.isVariable(x.X)
case *ast.IndexExpr:
return true
}
return false
}