From c14659c6754f4d91a3bec3cbb48c4e67b7421d13 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Tue, 23 Jul 2013 17:02:49 -0700 Subject: [PATCH] Fix bug in lGetConstantInt() in parse.yy. Previously, we weren't handling signed/unsigned constant types correctly. --- parse.yy | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/parse.yy b/parse.yy index 6ed2a43d..4b315776 100644 --- a/parse.yy +++ b/parse.yy @@ -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); 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; } }