mirror of
https://github.com/golang/go
synced 2024-11-22 04:54:42 -07:00
gc: rewrite complex /= to l = l / r.
Fixes #1368. R=rsc, ejsherry CC=golang-dev https://golang.org/cl/3811042
This commit is contained in:
parent
71793d4b42
commit
4e5a59591b
@ -975,13 +975,15 @@ walkexpr(Node **np, NodeList **init)
|
|||||||
* on 386, rewrite float ops into l = l op r.
|
* on 386, rewrite float ops into l = l op r.
|
||||||
* everywhere, rewrite map 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 string += into l = l op r.
|
||||||
|
* everywhere, rewrite complex /= into l = l op r.
|
||||||
* TODO(rsc): Maybe this rewrite should be done always?
|
* TODO(rsc): Maybe this rewrite should be done always?
|
||||||
*/
|
*/
|
||||||
et = n->left->type->etype;
|
et = n->left->type->etype;
|
||||||
if((widthptr == 4 && (et == TUINT64 || et == TINT64)) ||
|
if((widthptr == 4 && (et == TUINT64 || et == TINT64)) ||
|
||||||
(thechar == '8' && isfloat[et]) ||
|
(thechar == '8' && isfloat[et]) ||
|
||||||
l->op == OINDEXMAP ||
|
l->op == OINDEXMAP ||
|
||||||
et == TSTRING) {
|
et == TSTRING ||
|
||||||
|
(iscomplex[et] && n->etype == ODIV)) {
|
||||||
l = safeexpr(n->left, init);
|
l = safeexpr(n->left, init);
|
||||||
a = l;
|
a = l;
|
||||||
if(a->op == OINDEXMAP) {
|
if(a->op == OINDEXMAP) {
|
||||||
|
18
test/fixedbugs/bug315.go
Normal file
18
test/fixedbugs/bug315.go
Normal file
@ -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
|
||||||
|
*/
|
Loading…
Reference in New Issue
Block a user