summaryrefslogtreecommitdiff
path: root/src/cmd/gc/const.c
diff options
context:
space:
mode:
authorR?my Oudompheng <oudomphe@phare.normalesup.org>2011-12-07 16:18:50 -0500
committerR?my Oudompheng <oudomphe@phare.normalesup.org>2011-12-07 16:18:50 -0500
commitb6e54561d69ee8620aa41682eba96935ca420bde (patch)
treef11df49310be415c206fc27d866ce21598a720de /src/cmd/gc/const.c
parent818a16067831ea32d86f4e391bfff68ecb66a803 (diff)
downloadgo-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.c8
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;