// 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;
}
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):
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):
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;