]> Cypherpunks repositories - gostls13.git/commitdiff
gc: bug265
authorRuss Cox <rsc@golang.org>
Mon, 29 Mar 2010 22:27:59 +0000 (15:27 -0700)
committerRuss Cox <rsc@golang.org>
Mon, 29 Mar 2010 22:27:59 +0000 (15:27 -0700)
Fixes #700.

R=ken2
CC=golang-dev
https://golang.org/cl/839041

src/cmd/gc/walk.c
test/fixedbugs/bug265.go [moved from test/bugs/bug265.go with 100% similarity]
test/golden.out

index fa6157bb027a38b6f81e446d0d53fc137875e775..b64d58e7fee68a527c2fb57e3023277d28ccc87e 100644 (file)
@@ -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;
similarity index 100%
rename from test/bugs/bug265.go
rename to test/fixedbugs/bug265.go
index f83f15996ca3b9e2df7bd2f343f4eddf65ea5be9..9e08b20e01f6301c7e996d152d889d307bb04b13 100644 (file)
@@ -192,6 +192,3 @@ bal
 barCount != 1
 panic PC=xxx
 BUG
-
-=========== bugs/bug265.go
-BUG