Commit 0aa1b150 authored by Russ Cox's avatar Russ Cox

shift typechecking bugs

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

R=ken
OCL=31244
CL=31244
parent 908cd8f8
......@@ -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):
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment