mirror of
https://github.com/golang/go
synced 2024-11-23 04:00:03 -07:00
cmd/compile: fix defer/go calls to variadic unsafe-uintptr functions
Before generating wrapper function, turn any f(a, b, []T{c, d, e}...) calls back into f(a, b, c, d, e). This allows the existing code for recognizing and specially handling unsafe.Pointer->uintptr conversions to correctly handle variadic arguments too. Fixes #41460. Change-Id: I0a1255abdd1bd5dafd3e89547aedd4aec878394c Reviewed-on: https://go-review.googlesource.com/c/go/+/263297 Trust: Matthew Dempsky <mdempsky@google.com> Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
This commit is contained in:
parent
30119bcca9
commit
76a615b20a
@ -3881,6 +3881,16 @@ func wrapCall(n *Node, init *Nodes) *Node {
|
||||
}
|
||||
|
||||
isBuiltinCall := n.Op != OCALLFUNC && n.Op != OCALLMETH && n.Op != OCALLINTER
|
||||
|
||||
// Turn f(a, b, []T{c, d, e}...) back into f(a, b, c, d, e).
|
||||
if !isBuiltinCall && n.IsDDD() {
|
||||
last := n.List.Len() - 1
|
||||
if va := n.List.Index(last); va.Op == OSLICELIT {
|
||||
n.List.Set(append(n.List.Slice()[:last], va.List.Slice()...))
|
||||
n.SetIsDDD(false)
|
||||
}
|
||||
}
|
||||
|
||||
// origArgs keeps track of what argument is uintptr-unsafe/unsafe-uintptr conversion.
|
||||
origArgs := make([]*Node, n.List.Len())
|
||||
t := nod(OTFUNC, nil, nil)
|
||||
|
@ -34,9 +34,6 @@ func test(s string, p, q uintptr, rest ...uintptr) int {
|
||||
panic(s + ": q failed")
|
||||
}
|
||||
for _, r := range rest {
|
||||
// TODO(mdempsky): Remove.
|
||||
break
|
||||
|
||||
if *(*string)(unsafe.Pointer(r)) != "ok" {
|
||||
panic(s + ": r[i] failed")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user