1
0
mirror of https://github.com/golang/go synced 2024-11-24 22:00:09 -07:00

gc: test + fix escape analysis bug

R=lvd
CC=golang-dev
https://golang.org/cl/5333049
This commit is contained in:
Russ Cox 2011-11-01 11:02:43 -04:00
parent 1fe22d2d24
commit b4df33a6ea
2 changed files with 89 additions and 70 deletions

View File

@ -239,6 +239,7 @@ esc(Node *n)
case OPROC: case OPROC:
// go f(x) - f and x escape // go f(x) - f and x escape
escassign(&theSink, n->left->left); escassign(&theSink, n->left->left);
escassign(&theSink, n->left->right); // ODDDARG for call
for(ll=n->left->list; ll; ll=ll->next) for(ll=n->left->list; ll; ll=ll->next)
escassign(&theSink, ll->n); escassign(&theSink, ll->n);
break; break;

View File

@ -6,7 +6,10 @@
package foo package foo
import "unsafe" import (
"fmt"
"unsafe"
)
var gxx *int var gxx *int
@ -993,3 +996,18 @@ L100:
goto L99 goto L99
goto L100 goto L100
} }
func foo121() {
for i := 0; i < 10; i++ {
defer myprint(nil, i) // ERROR "[.][.][.] argument escapes to heap"
go myprint(nil, i) // ERROR "[.][.][.] argument escapes to heap"
}
}
// same as foo121 but check across import
func foo121b() {
for i := 0; i < 10; i++ {
defer fmt.Printf("%d", i) // ERROR "[.][.][.] argument escapes to heap"
go fmt.Printf("%d", i) // ERROR "[.][.][.] argument escapes to heap"
}
}