diff options
author | Russ Cox <rsc@golang.org> | 2014-02-13 20:59:39 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-02-13 20:59:39 -0500 |
commit | a069cf048dcfcd4c657d59b40ff318c8ab09b65c (patch) | |
tree | cb55e77288611e0a7429ed2332cd5b87662981ef /test/escape5.go | |
parent | e5d742fcadf9677a40336d6cecd3ff464a94730f (diff) | |
download | go-a069cf048dcfcd4c657d59b40ff318c8ab09b65c.tar.gz go-a069cf048dcfcd4c657d59b40ff318c8ab09b65c.zip |
cmd/gc: distinguish unnamed vs blank-named return variables better
Before, an unnamed return value turned into an ONAME node n with n->sym
named ~anon%d, and n->orig == n.
A blank-named return value turned into an ONAME node n with n->sym
named ~anon%d but n->orig == the original blank n. Code generation and
printing uses n->orig, so that this node formatted as _.
But some code does not use n->orig. In particular the liveness code does
not know about the n->orig convention and so mishandles blank identifiers.
It is possible to fix but seemed better to avoid the confusion entirely.
Now the first kind of node is named ~r%d and the second ~b%d; both have
n->orig == n, so that it doesn't matter whether code uses n or n->orig.
After this change the ->orig field is only used for other kinds of expressions,
not for ONAME nodes.
This requires distinguishing ~b from ~r names in a few places that care.
It fixes a liveness analysis bug without actually changing the liveness code.
TBR=ken2
CC=golang-codereviews
https://golang.org/cl/63630043
Diffstat (limited to 'test/escape5.go')
-rw-r--r-- | test/escape5.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/escape5.go b/test/escape5.go index c9646872d5..a33daeee18 100644 --- a/test/escape5.go +++ b/test/escape5.go @@ -17,19 +17,19 @@ func leaktoret(p *int) *int { // ERROR "leaking param: p to result" return p } -func leaktoret2(p *int) (*int, *int) { // ERROR "leaking param: p to result .anon1" "leaking param: p to result .anon2" +func leaktoret2(p *int) (*int, *int) { // ERROR "leaking param: p to result ~r1" "leaking param: p to result ~r2" return p, p } -func leaktoret22(p, q *int) (*int, *int) { // ERROR "leaking param: p to result .anon2" "leaking param: q to result .anon3" +func leaktoret22(p, q *int) (*int, *int) { // ERROR "leaking param: p to result ~r2" "leaking param: q to result ~r3" return p, q } -func leaktoret22b(p, q *int) (*int, *int) { // ERROR "leaking param: p to result .anon3" "leaking param: q to result .anon2" +func leaktoret22b(p, q *int) (*int, *int) { // ERROR "leaking param: p to result ~r3" "leaking param: q to result ~r2" return leaktoret22(q, p) } -func leaktoret22c(p, q *int) (*int, *int) { // ERROR "leaking param: p to result .anon3" "leaking param: q to result .anon2" +func leaktoret22c(p, q *int) (*int, *int) { // ERROR "leaking param: p to result ~r3" "leaking param: q to result ~r2" r, s := leaktoret22(q, p) return r, s } |