Commit 5efd5624 authored by Luuk van Dijk's avatar Luuk van Dijk

cmd/gc: fix codegen reordering for expressions involving && and ||

Fixes #2821.

R=rsc
CC=golang-dev
https://golang.org/cl/5606061
parent 02fb0211
......@@ -1670,6 +1670,11 @@ ullmancalc(Node *n)
if(n == N)
return;
if(n->ninit != nil) {
ul = UINF;
goto out;
}
switch(n->op) {
case OREGISTER:
case OLITERAL:
......@@ -3577,4 +3582,5 @@ addinit(Node **np, NodeList *init)
break;
}
n->ninit = concat(init, n->ninit);
n->ullman = UINF;
}
......@@ -1203,10 +1203,11 @@ walkexpr(Node **np, NodeList **init)
fatal("missing switch %O", n->op);
ret:
ullmancalc(n);
if(debug['w'] && n != N)
dump("walk", n);
ullmancalc(n);
lineno = lno;
*np = n;
}
......
// $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
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment