about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
-rw-r--r--lib/Expr/Parser.cpp5
-rw-r--r--test/Expr/Parser/Concat64.pc11
2 files changed, 15 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.
diff --git a/test/Expr/Parser/Concat64.pc b/test/Expr/Parser/Concat64.pc
new file mode 100644
index 00000000..e57e9760
--- /dev/null
+++ b/test/Expr/Parser/Concat64.pc
@@ -0,0 +1,11 @@
+# RUN: kleaver --print-ast %s
+
+(query [(Eq 0
+            (Concat w64 (Read w8 7 arr1)
+            (Concat w56 (Read w8 6 arr1)
+            (Concat w48 (Read w8 5 arr1)
+            (Concat w40 (Read w8 4 arr1)
+            (Concat w32 (Read w8 3 arr1)
+            (Concat w24 (Read w8 2 arr1)
+            (Concat w16 (Read w8 1 arr1) (Read w8 0 arr1)))))))))]
+       false)