summaryrefslogtreecommitdiff
path: root/src/cmd/gc/const.c
diff options
context:
space:
mode:
authorKen Thompson <ken@golang.org>2008-06-15 20:24:30 -0700
committerKen Thompson <ken@golang.org>2008-06-15 20:24:30 -0700
commitf955c006f9353c2d692c9a0d0ee13cf4c0013364 (patch)
treefb752fc19ce6aaf23a67e513f40ea0c80d557560 /src/cmd/gc/const.c
parent93d1800882db478d90ce6b002cdece91ef28ae17 (diff)
downloadgolang-f955c006f9353c2d692c9a0d0ee13cf4c0013364.tar.gz
now checks for lvalue/rvalue context of
expressions. start of generics for calling builtin functions start of map type 'any' demoted from reserved word to type SVN=122808
Diffstat (limited to 'src/cmd/gc/const.c')
-rw-r--r--src/cmd/gc/const.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/cmd/gc/const.c b/src/cmd/gc/const.c
index cc8e7321a..0a530b47d 100644
--- a/src/cmd/gc/const.c
+++ b/src/cmd/gc/const.c
@@ -10,14 +10,15 @@ convlit(Node *n, Type *t)
{
int et;
- if(n->op != OLITERAL)
+ if(n == N || n->op != OLITERAL || t == T)
return;
- if(t == T)
+
+ if(t->etype == TANY || isptrto(t, TANY)) {
+ defaultlit(n);
return;
+ }
- n->type = t;
et = t->etype;
-
switch(whatis(n)) {
case Wlitint:
if(isptrto(t, TSTRING)) {
@@ -72,6 +73,7 @@ convlit(Node *n, Type *t)
}
goto bad1;
}
+ n->type = t;
return;
bad1:
@@ -122,9 +124,17 @@ evconst(Node *n)
case Wlitstr:
break;
}
+
if(wl != wr) {
- yyerror("illegal combination of literals %d %d", nl->etype, nr->etype);
- return;
+ if(wl == Wlitfloat && wr == Wlitint)
+ convlit(n->right, n->left->type);
+ else
+ if(wl == Wlitint && wr == Wlitfloat)
+ convlit(n->left, n->right->type);
+ else {
+ yyerror("illegal combination of literals %d %d", nl->etype, nr->etype);
+ return;
+ }
}
switch(TUP(n->op, wl)) {