mirror of
https://github.com/golang/go
synced 2024-11-25 02:47:58 -07:00
cmd/gc: fix codegen reordering for expressions involving && and ||
Fixes #2821. R=rsc CC=golang-dev https://golang.org/cl/5606061
This commit is contained in:
parent
02fb021161
commit
5efd5624cc
@ -1670,6 +1670,11 @@ ullmancalc(Node *n)
|
|||||||
if(n == N)
|
if(n == N)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(n->ninit != nil) {
|
||||||
|
ul = UINF;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
switch(n->op) {
|
switch(n->op) {
|
||||||
case OREGISTER:
|
case OREGISTER:
|
||||||
case OLITERAL:
|
case OLITERAL:
|
||||||
@ -3577,4 +3582,5 @@ addinit(Node **np, NodeList *init)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
n->ninit = concat(init, n->ninit);
|
n->ninit = concat(init, n->ninit);
|
||||||
|
n->ullman = UINF;
|
||||||
}
|
}
|
||||||
|
@ -1203,10 +1203,11 @@ walkexpr(Node **np, NodeList **init)
|
|||||||
fatal("missing switch %O", n->op);
|
fatal("missing switch %O", n->op);
|
||||||
|
|
||||||
ret:
|
ret:
|
||||||
|
ullmancalc(n);
|
||||||
|
|
||||||
if(debug['w'] && n != N)
|
if(debug['w'] && n != N)
|
||||||
dump("walk", n);
|
dump("walk", n);
|
||||||
|
|
||||||
ullmancalc(n);
|
|
||||||
lineno = lno;
|
lineno = lno;
|
||||||
*np = n;
|
*np = n;
|
||||||
}
|
}
|
||||||
|
25
test/fixedbugs/bug406.go
Normal file
25
test/fixedbugs/bug406.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// $G $D/$F.go && $L $F.$A && ./$A.out || echo "Bug406"
|
||||||
|
|
||||||
|
// Copyright 2012 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 2821
|
||||||
|
package main
|
||||||
|
|
||||||
|
type matrix struct {
|
||||||
|
e []int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a matrix) equal() bool {
|
||||||
|
for _ = range a.e {
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var a matrix
|
||||||
|
var i interface{}
|
||||||
|
i = true && a.equal()
|
||||||
|
_ = i
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user