pedantic>1: "char c=200" is not allowed (evaluates to -56)
*/
-void checkConstantRange(sym_link *ltype, double v, char *msg, int pedantic) {
+void checkConstantRange(sym_link *ltype, value *val, char *msg, int pedantic) {
LONG_LONG max = (LONG_LONG) 1 << bitsForType(ltype);
char message[132]="";
int warnings=0;
int negative=0;
+ long v=SPEC_CVAL(val->type).v_long;
#if 0
// this could be a good idea
return;
}
- if (v<0) {
+ if (!SPEC_USIGN(val->type) && v<0) {
negative=1;
- // if not pedantic: -1 equals to 0xf..f
- if (SPEC_USIGN(ltype) && (!pedantic ? v!=-1 : 1)) {
+ if (SPEC_USIGN(ltype) && (pedantic>1)) {
warnings++;
}
v=-v;
if (IS_INTEGRAL (ltype) && IS_VALOP (right) && IS_LITERAL (rtype))
{
checkConstantRange(ltype,
- operandLitValue(right), "compare operation", 1);
+ OP_VALUE(right), "compare operation", 1);
}
ctype = usualBinaryConversions (&left, &right);
if (IS_INTEGRAL (ltype) && right->type == VALUE && IS_LITERAL (rtype))
{
checkConstantRange(ltype,
- operandLitValue(right), "= operation", 0);
+ OP_VALUE(right), "= operation", 0);
}
/* if the left & right type don't exactly match */
#define OP_SYMBOL(op) op->operand.symOperand
#define OP_SYM_TYPE(op) op->operand.symOperand->type
#define OP_SYM_ETYPE(op) op->operand.symOperand->etype
+#define OP_VALUE(op) op->operand.valOperand
#define SPIL_LOC(op) op->operand.symOperand->usl.spillLoc
#define OP_LIVEFROM(op) op->operand.symOperand->liveFrom
#define OP_LIVETO(op) op->operand.symOperand->liveTo
SPEC_NOUN (val->type) = V_INT;
SPEC_SCLS (val->type) = S_LITERAL;
- /* set the _unsigned flag if 'uU' found */
- if (strchr (s, 'u') || strchr (s, 'U'))
+ /* set the _unsigned flag if 'uUoOxX' found */
+ if (strchr (s, 'u') || strchr (s, 'U') ||
+ strchr (s, 'o') || strchr (s, 'O') ||
+ strchr (s, 'x') || strchr (s, 'x'))
SPEC_USIGN (val->type) = 1;
/* set the _long flag if 'lL' is found */
val->type = val->etype = newLink ();
val->type->class = SPECIFIER;
SPEC_NOUN (val->type) = V_CHAR;
+ SPEC_USIGN(val->type) = 1;
SPEC_SCLS (val->type) = S_LITERAL;
s++; /* get rid of quotation */