diff options
author | R?my Oudompheng <oudomphe@phare.normalesup.org> | 2011-12-07 16:18:50 -0500 |
---|---|---|
committer | R?my Oudompheng <oudomphe@phare.normalesup.org> | 2011-12-07 16:18:50 -0500 |
commit | b6e54561d69ee8620aa41682eba96935ca420bde (patch) | |
tree | f11df49310be415c206fc27d866ce21598a720de /src/cmd/gc/const.c | |
parent | 818a16067831ea32d86f4e391bfff68ecb66a803 (diff) | |
download | go-b6e54561d69ee8620aa41682eba96935ca420bde.tar.gz |
gc: keep pointer to original node in constant rewrites.
This allows printing meaningful expressions in error messages
instead of evaluated constants.
Fixes issue 2276.
R=golang-dev, rsc
CC=golang-dev, remy
http://codereview.appspot.com/5432082
Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/cmd/gc/const.c')
-rw-r--r-- | src/cmd/gc/const.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/cmd/gc/const.c b/src/cmd/gc/const.c index 96abf1a65..dd4c4433b 100644 --- a/src/cmd/gc/const.c +++ b/src/cmd/gc/const.c @@ -842,8 +842,12 @@ unary: } ret: - norig = n->orig; - // rewrite n in place. + if(n == n->orig) { + // duplicate node for n->orig. + norig = nod(OLITERAL, N, N); + *norig = *n; + } else + norig = n->orig; *n = *nl; // restore value of n->orig. n->orig = norig; |