1
0
mirror of https://github.com/golang/go synced 2024-10-03 06:21:21 -06:00

shift typechecking bugs

x << "a"
	1 << int(2)

R=ken
OCL=31244
CL=31244
This commit is contained in:
Russ Cox 2009-07-06 23:33:17 -07:00
parent 908cd8f857
commit 0aa1b1508a
2 changed files with 12 additions and 5 deletions

View File

@ -345,6 +345,8 @@ evconst(Node *n)
// right must be unsigned.
// left can be ideal.
defaultlit(nr, types[TUINT]);
if(nr->type && (issigned[nr->type->etype] || !isint[nr->type->etype]))
goto illegal;
break;
}
@ -367,9 +369,11 @@ evconst(Node *n)
switch(TUP(n->op, v.ctype)) {
default:
illegal:
yyerror("illegal constant expression %T %O %T",
nl->type, n->op, nr->type);
n->diag = 1;
if(!n->diag) {
yyerror("illegal constant expression: %T %O %T",
nl->type, n->op, nr->type);
n->diag = 1;
}
return;
case TUP(OADD, CTINT):
@ -551,7 +555,10 @@ unary:
switch(TUP(n->op, v.ctype)) {
default:
yyerror("illegal constant expression %O %T", n->op, nl->type);
if(!n->diag) {
yyerror("illegal constant expression %O %T", n->op, nl->type);
n->diag = 1;
}
return;
case TUP(OPLUS, CTINT):

View File

@ -704,7 +704,7 @@ loop:
defaultlit(n->right, types[TUINT]);
if(n->left->type == T || n->right->type == T)
goto ret;
if(issigned[n->right->type->etype])
if(issigned[n->right->type->etype] || !isint[n->right->type->etype])
goto badt;
// check of n->left->type happens in second switch.
break;