diff options
author | Russ Cox <rsc@golang.org> | 2010-03-29 15:27:59 -0700 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2010-03-29 15:27:59 -0700 |
commit | 7f29727c0c5c3e6f12cadbfe988a3edade1d4e2a (patch) | |
tree | be76e183f5ff4f9d4a07d59536b08c4647a8126d | |
parent | 5e7c998c247970cf7c1d95075317f91f6c38a534 (diff) | |
download | golang-7f29727c0c5c3e6f12cadbfe988a3edade1d4e2a.tar.gz |
gc: bug265
Fixes issue 700.
R=ken2
CC=golang-dev
http://codereview.appspot.com/839041
-rw-r--r-- | src/cmd/gc/walk.c | 25 | ||||
-rw-r--r-- | test/fixedbugs/bug265.go (renamed from test/bugs/bug265.go) | 0 | ||||
-rw-r--r-- | test/golden.out | 3 |
3 files changed, 20 insertions, 8 deletions
diff --git a/src/cmd/gc/walk.c b/src/cmd/gc/walk.c index fa6157bb0..b64d58e7f 100644 --- a/src/cmd/gc/walk.c +++ b/src/cmd/gc/walk.c @@ -328,6 +328,23 @@ samelist(NodeList *a, NodeList *b) return a == b; } +static int +paramoutheap(Node *fn) +{ + NodeList *l; + + for(l=fn->dcl; l; l=l->next) { + switch(l->n->class) { + case PPARAMOUT|PHEAP: + return 1; + case PAUTO: + case PAUTO|PHEAP: + // stop early - parameters are over + return 0; + } + } + return 0; +} void walkstmt(Node **np) @@ -441,11 +458,9 @@ walkstmt(Node **np) case ORETURN: walkexprlist(n->list, &n->ninit); - if(curfn->type->outnamed && count(n->list) != 1) { - if(n->list == nil) { - // print("special return\n"); - break; - } + if(n->list == nil) + break; + if((curfn->type->outnamed && count(n->list) > 1) || paramoutheap(curfn)) { // assign to the function out parameters, // so that reorder3 can fix up conflicts rl = nil; diff --git a/test/bugs/bug265.go b/test/fixedbugs/bug265.go index 55f32ecec..55f32ecec 100644 --- a/test/bugs/bug265.go +++ b/test/fixedbugs/bug265.go diff --git a/test/golden.out b/test/golden.out index f83f15996..9e08b20e0 100644 --- a/test/golden.out +++ b/test/golden.out @@ -192,6 +192,3 @@ bal barCount != 1 panic PC=xxx BUG - -=========== bugs/bug265.go -BUG |