diff options
author | Russ Cox <rsc@golang.org> | 2014-02-15 20:01:15 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-02-15 20:01:15 -0500 |
commit | d378f86d75dd2d649e456ccc4039ed87f1a7ae64 (patch) | |
tree | fc4834c956ce5a75aac6172d7f86300cc32d8843 /src | |
parent | 8973608325fbf5895e9446bfad248ee840641792 (diff) | |
download | go-d378f86d75dd2d649e456ccc4039ed87f1a7ae64.tar.gz |
cmd/gc: record &x[0] as taking address of x, if x is an array
Not recording the address being taken was causing
the liveness analysis not to preserve x in the absence
of direct references to x, which in turn was making the
net test fail with GOGC=0.
In addition to the test, this fixes a bug wherein
GOGC=0 go test -short net
crashed if liveness analysis was in use (like at tip, not like Go 1.2).
TBR=ken2
CC=golang-codereviews
https://codereview.appspot.com/64470043
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd/gc/go.h | 1 | ||||
-rw-r--r-- | src/cmd/gc/typecheck.c | 3 | ||||
-rw-r--r-- | src/cmd/gc/walk.c | 2 |
3 files changed, 4 insertions, 2 deletions
diff --git a/src/cmd/gc/go.h b/src/cmd/gc/go.h index 049809e61..e5d12a834 100644 --- a/src/cmd/gc/go.h +++ b/src/cmd/gc/go.h @@ -1452,6 +1452,7 @@ void walkstmt(Node **np); void walkstmtlist(NodeList *l); Node* conv(Node*, Type*); int candiscard(Node*); +Node* outervalue(Node*); /* * arch-specific ggen.c/gsubr.c/gobj.c/pgen.c/plive.c diff --git a/src/cmd/gc/typecheck.c b/src/cmd/gc/typecheck.c index 9e1ec1012..0ef497f62 100644 --- a/src/cmd/gc/typecheck.c +++ b/src/cmd/gc/typecheck.c @@ -721,7 +721,8 @@ reswitch: if(n->left->type == T) goto error; checklvalue(n->left, "take the address of"); - for(l=n->left; l->op == ODOT; l=l->left) + r = outervalue(n->left); + for(l = n->left; l != r; l = l->left) l->addrtaken = 1; if(l->orig != l && l->op == ONAME) fatal("found non-orig name node %N", l); diff --git a/src/cmd/gc/walk.c b/src/cmd/gc/walk.c index e9f4c25c4..fe07490cb 100644 --- a/src/cmd/gc/walk.c +++ b/src/cmd/gc/walk.c @@ -2205,7 +2205,7 @@ reorder3save(Node **np, NodeList *all, NodeList *stop, NodeList **early) * what's the outer value that a write to n affects? * outer value means containing struct or array. */ -static Node* +Node* outervalue(Node *n) { for(;;) { |