From: Russ Cox Date: Tue, 7 Jul 2009 06:33:17 +0000 (-0700) Subject: shift typechecking bugs X-Git-Tag: weekly.2009-11-06~1240 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0aa1b1508a2a6197773751466c0ea1e1449e4a8e;p=gostls13.git shift typechecking bugs x << "a" 1 << int(2) R=ken OCL=31244 CL=31244 --- diff --git a/src/cmd/gc/const.c b/src/cmd/gc/const.c index d45e6136a1..a0a0806791 100644 --- a/src/cmd/gc/const.c +++ b/src/cmd/gc/const.c @@ -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): diff --git a/src/cmd/gc/walk.c b/src/cmd/gc/walk.c index 398d61ec69..e0617259f4 100644 --- a/src/cmd/gc/walk.c +++ b/src/cmd/gc/walk.c @@ -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;