mirror of
https://github.com/golang/go
synced 2024-09-15 22:20:06 +00:00
cmd/compile: don't skip PPARAMOUT in esccall after varargs
Fixes bug I introduced in CL 21202. Fixes #15013. Change-Id: I2344d7e22b8273425a0a56f4a77588b5c6e4d8c6 Reviewed-on: https://go-review.googlesource.com/21270 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
17f6e5396b
commit
777a77b4d2
|
@ -1478,17 +1478,16 @@ func esccall(e *EscState, n *Node, up *Node) {
|
|||
lls := ll.Slice()
|
||||
sawRcvr := false
|
||||
var src *Node
|
||||
DclLoop:
|
||||
for _, n2 := range fn.Name.Defn.Func.Dcl {
|
||||
switch n2.Class {
|
||||
case PPARAM:
|
||||
if n.Op != OCALLFUNC && !sawRcvr {
|
||||
escassignNilWhy(e, n2, n.Left.Left, "call receiver")
|
||||
sawRcvr = true
|
||||
continue DclLoop
|
||||
continue
|
||||
}
|
||||
if len(lls) == 0 {
|
||||
continue DclLoop
|
||||
continue
|
||||
}
|
||||
src = lls[0]
|
||||
if n2.Isddd && !n.Isddd {
|
||||
|
@ -1502,7 +1501,17 @@ func esccall(e *EscState, n *Node, up *Node) {
|
|||
}
|
||||
escassignNilWhy(e, n2, src, "arg to recursive call")
|
||||
if src != lls[0] {
|
||||
break DclLoop
|
||||
// "..." arguments are untracked
|
||||
for _, n2 := range lls {
|
||||
if Debug['m'] > 3 {
|
||||
fmt.Printf("%v::esccall:: ... <- %v, untracked\n", linestr(lineno), Nconv(n2, FmtShort))
|
||||
}
|
||||
escassignSinkNilWhy(e, src, n2, "... arg to recursive call")
|
||||
}
|
||||
// No more PPARAM processing, but keep
|
||||
// going for PPARAMOUT.
|
||||
lls = nil
|
||||
continue
|
||||
}
|
||||
lls = lls[1:]
|
||||
|
||||
|
@ -1511,14 +1520,6 @@ func esccall(e *EscState, n *Node, up *Node) {
|
|||
}
|
||||
}
|
||||
|
||||
// "..." arguments are untracked
|
||||
for _, n2 := range lls {
|
||||
if Debug['m'] > 3 {
|
||||
fmt.Printf("%v::esccall:: ... <- %v, untracked\n", linestr(lineno), Nconv(n2, FmtShort))
|
||||
}
|
||||
escassignSinkNilWhy(e, src, n2, "... arg to recursive call")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
24
test/fixedbugs/issue15013.go
Normal file
24
test/fixedbugs/issue15013.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
// compile
|
||||
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// CL 21202 introduced a compiler crash in the handling of a varargs
|
||||
// function in the same recursive group as a function that calls it.
|
||||
// Nothing in the standard library caught the problem, so adding a test.
|
||||
|
||||
package p
|
||||
|
||||
func F1(p *int, a ...*int) (int, *int) {
|
||||
if p == nil {
|
||||
return F2(), a[0]
|
||||
}
|
||||
return 0, a[0]
|
||||
}
|
||||
|
||||
func F2() int {
|
||||
var i0, i1 int
|
||||
a, _ := F1(&i0, &i1)
|
||||
return a
|
||||
}
|
Loading…
Reference in a new issue