about summary refs log tree commit diff homepage
path: root/lib/Expr/Parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Expr/Parser.cpp')
-rw-r--r--lib/Expr/Parser.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Expr/Parser.cpp b/lib/Expr/Parser.cpp
index 9e1849ae..3bbe3334 100644
--- a/lib/Expr/Parser.cpp
+++ b/lib/Expr/Parser.cpp
@@ -1224,7 +1224,10 @@ ExprResult ParserImpl::ParseNumberToken(Expr::Width Type, const Token &Tok) {
   if (HasMinus)
     Val = -Val;
 
-  return ExprResult(ConstantExpr::alloc(Val.trunc(Type).getZExtValue(), Type));
+  if (Type < Val.getBitWidth())
+    Val = Val.trunc(Type);
+
+  return ExprResult(ConstantExpr::alloc(Val.getZExtValue(), Type));
 }
 
 /// ParseTypeSpecifier - Parse a type specifier.