Skip to content

Commit

Permalink
gc: bug265
Browse files Browse the repository at this point in the history
Fixes #700.

R=ken2
CC=golang-dev
https://golang.org/cl/839041
  • Loading branch information
rsc committed Mar 29, 2010
1 parent b880543 commit 3908c16
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
25 changes: 20 additions & 5 deletions src/cmd/gc/walk.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
File renamed without changes.
3 changes: 0 additions & 3 deletions test/golden.out
Expand Up @@ -192,6 +192,3 @@ bal
barCount != 1
panic PC=xxx
BUG

=========== bugs/bug265.go
BUG

0 comments on commit 3908c16

Please sign in to comment.