]> Cypherpunks repositories - gostls13.git/commitdiff
gc: handle function calls in arguments to builtin complex operations.
authorLuuk van Dijk <lvd@golang.org>
Mon, 23 Jan 2012 15:56:57 +0000 (16:56 +0100)
committerLuuk van Dijk <lvd@golang.org>
Mon, 23 Jan 2012 15:56:57 +0000 (16:56 +0100)
Fixes #2582

R=rsc
CC=golang-dev
https://golang.org/cl/5574044

src/cmd/gc/cplx.c
test/fixedbugs/bug401.go [new file with mode: 0644]

index 52038e71c3cf66a136f1448dc15c07f1fc2013e3..dea7bc3bbb59fbc8835f25deb8bd22330f393a1b 100644 (file)
@@ -204,6 +204,8 @@ complexgen(Node *n, Node *res)
        case OIND:
        case ONAME:     // PHEAP or PPARAMREF var
        case OCALLFUNC:
+       case OCALLMETH:
+       case OCALLINTER:
                igen(n, &n1, res);
                complexmove(&n1, res);
                regfree(&n1);
diff --git a/test/fixedbugs/bug401.go b/test/fixedbugs/bug401.go
new file mode 100644 (file)
index 0000000..baad1bc
--- /dev/null
@@ -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())
+}
\ No newline at end of file