1
0
mirror of https://github.com/golang/go synced 2024-11-22 03:44:39 -07:00

gc: handle function calls in arguments to builtin complex operations.

Fixes #2582

R=rsc
CC=golang-dev
https://golang.org/cl/5574044
This commit is contained in:
Luuk van Dijk 2012-01-23 16:56:57 +01:00
parent 858f0b4d95
commit 5ad9e2db28
2 changed files with 31 additions and 0 deletions

View File

@ -204,6 +204,8 @@ complexgen(Node *n, Node *res)
case OIND: case OIND:
case ONAME: // PHEAP or PPARAMREF var case ONAME: // PHEAP or PPARAMREF var
case OCALLFUNC: case OCALLFUNC:
case OCALLMETH:
case OCALLINTER:
igen(n, &n1, res); igen(n, &n1, res);
complexmove(&n1, res); complexmove(&n1, res);
regfree(&n1); regfree(&n1);

29
test/fixedbugs/bug401.go Normal file
View File

@ -0,0 +1,29 @@
// $G $D/$F.go || echo "Bug398"
// Copyright 2011 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.
// Issue 2582
package foo
type T struct {}
func (T) cplx() complex128 {
for false {} // avoid inlining
return complex(1,0)
}
type I interface {
cplx() complex128
}
func f(e float32, t T) {
_ = real(t.cplx())
_ = imag(t.cplx())
var i I
i = t
_ = real(i.cplx())
_ = imag(i.cplx())
}