summaryrefslogtreecommitdiff
path: root/src/cmd/gc/const.c
diff options
context:
space:
mode:
authorKen Thompson <ken@golang.org>2008-12-12 13:10:36 -0800
committerKen Thompson <ken@golang.org>2008-12-12 13:10:36 -0800
commit529b027f784bb9b94e2057282fd5ee34b9ef361a (patch)
tree3dfc035db9d42dac99214a13bf7b4d6a4a35b75d /src/cmd/gc/const.c
parenta8e691c569c51cbb07e0af00d85503602f0d6bf5 (diff)
downloadgolang-529b027f784bb9b94e2057282fd5ee34b9ef361a.tar.gz
bug104
R=r OCL=21082 CL=21082
Diffstat (limited to 'src/cmd/gc/const.c')
-rw-r--r--src/cmd/gc/const.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/cmd/gc/const.c b/src/cmd/gc/const.c
index a61ebe5ee..d8e38300d 100644
--- a/src/cmd/gc/const.c
+++ b/src/cmd/gc/const.c
@@ -34,7 +34,7 @@ truncfltlit(Mpflt *fv, Type *t)
}
void
-convlit(Node *n, Type *t)
+convlit1(Node *n, Type *t, int conv)
{
int et, wt;
@@ -92,21 +92,6 @@ convlit(Node *n, Type *t)
defaultlit(n);
return;
}
- if(isptrto(t, TSTRING)) {
- Rune rune;
- int l;
- String *s;
-
- rune = mpgetfix(n->val.u.xval);
- l = runelen(rune);
- s = mal(sizeof(*s)+l);
- s->len = l;
- runetochar((char*)(s->s), &rune);
-
- n->val.u.sval = s;
- n->val.ctype = CTSTR;
- break;
- }
if(isint[et]) {
// int to int
if(mpcmpfixfix(n->val.u.xval, minintval[et]) < 0)
@@ -132,6 +117,25 @@ convlit(Node *n, Type *t)
truncfltlit(fv, t);
break;
}
+ if(!conv)
+ goto bad1;
+
+ // only done as string(CONST)
+ if(isptrto(t, TSTRING)) {
+ Rune rune;
+ int l;
+ String *s;
+
+ rune = mpgetfix(n->val.u.xval);
+ l = runelen(rune);
+ s = mal(sizeof(*s)+l);
+ s->len = l;
+ runetochar((char*)(s->s), &rune);
+
+ n->val.u.sval = s;
+ n->val.ctype = CTSTR;
+ break;
+ }
goto bad1;
case Wlitfloat:
@@ -187,6 +191,12 @@ bad3:
}
void
+convlit(Node *n, Type *t)
+{
+ convlit1(n, t, 0);
+}
+
+void
evconst(Node *n)
{
Node *nl, *nr;