Fix bug in lGetConstantInt() in parse.yy.

Previously, we weren't handling signed/unsigned constant types correctly.
This commit is contained in:
Matt Pharr
2013-07-23 17:02:49 -07:00
parent f7f281a256
commit c14659c675

View File

@@ -2278,7 +2278,11 @@ lGetConstantInt(Expr *expr, int *value, SourcePos pos, const char *usage) {
Error(pos, "%s must be representable with a 32-bit integer.", usage); Error(pos, "%s must be representable with a 32-bit integer.", usage);
return false; return false;
} }
*value = (int)ci->getZExtValue(); const Type *type = expr->GetType();
if (type->IsUnsignedType())
*value = (int)ci->getZExtValue();
else
*value = (int)ci->getSExtValue();
return true; return true;
} }
} }