summaryrefslogtreecommitdiff
path: root/src/cmd/gc/const.c
diff options
context:
space:
mode:
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)) {