summaryrefslogtreecommitdiff
path: root/src/cmd/gc/walk.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/gc/walk.c')
-rw-r--r--src/cmd/gc/walk.c25
1 files changed, 20 insertions, 5 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;