]> Cypherpunks repositories - gostls13.git/commitdiff
gc: rewrite complex /= to l = l / r.
authorPatrick Gavlin <pgavlin@gmail.com>
Tue, 4 Jan 2011 18:14:17 +0000 (13:14 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 4 Jan 2011 18:14:17 +0000 (13:14 -0500)
Fixes #1368.

R=rsc, ejsherry
CC=golang-dev
https://golang.org/cl/3811042

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

index 6e238f66168b068e1a7870e694b32dcf41f393d3..536c37701d74415445ade3f40d15cfeaa7e50779 100644 (file)
@@ -975,13 +975,15 @@ walkexpr(Node **np, NodeList **init)
                 * on 386, rewrite float ops into l = l op r.
                 * everywhere, rewrite map ops into l = l op r.
                 * everywhere, rewrite string += into l = l op r.
+                * everywhere, rewrite complex /= into l = l op r.
                 * TODO(rsc): Maybe this rewrite should be done always?
                 */
                et = n->left->type->etype;
                if((widthptr == 4 && (et == TUINT64 || et == TINT64)) ||
                   (thechar == '8' && isfloat[et]) ||
                   l->op == OINDEXMAP ||
-                  et == TSTRING) {
+                  et == TSTRING ||
+                  (iscomplex[et] && n->etype == ODIV)) {
                        l = safeexpr(n->left, init);
                        a = l;
                        if(a->op == OINDEXMAP) {
diff --git a/test/fixedbugs/bug315.go b/test/fixedbugs/bug315.go
new file mode 100644 (file)
index 0000000..198bae7
--- /dev/null
@@ -0,0 +1,18 @@
+// $G $D/$F.go || echo BUG: bug315
+
+// Copyright 2010 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 1368.
+
+package main
+
+func main() {
+       a := cmplx(2, 2)
+       a /= 2
+}
+
+/*
+bug315.go:13: internal compiler error: optoas: no entry DIV-complex
+*/