File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
src/solvers/smt2_incremental
unit/solvers/smt2_incremental Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,8 @@ extension_for_type(const typet &type)
164164 return smt_bit_vector_theoryt::sign_extend;
165165 if (can_cast_type<unsignedbv_typet>(type))
166166 return smt_bit_vector_theoryt::zero_extend;
167+ if (can_cast_type<bv_typet>(type))
168+ return smt_bit_vector_theoryt::zero_extend;
167169 UNREACHABLE;
168170}
169171
@@ -947,6 +949,9 @@ static smt_termt convert_to_smt_shift(
947949 INVARIANT (
948950 first_bit_vector_sort && second_bit_vector_sort,
949951 " Shift expressions are expected to have bit vector operands." );
952+ INVARIANT (
953+ shift.type () == shift.op0 ().type (),
954+ " Shift expression type must be equals to first operand type." );
950955 const std::size_t first_width = first_bit_vector_sort->bit_width ();
951956 const std::size_t second_width = second_bit_vector_sort->bit_width ();
952957 if (first_width > second_width)
@@ -958,10 +963,11 @@ static smt_termt convert_to_smt_shift(
958963 }
959964 else if (first_width < second_width)
960965 {
961- return factory (
966+ const auto result = factory (
962967 extension_for_type (shift.op0 ().type ())(second_width - first_width)(
963968 first_operand),
964969 second_operand);
970+ return smt_bit_vector_theoryt::extract (first_width - 1 , 0 )(result);
965971 }
966972 else
967973 {
Original file line number Diff line number Diff line change @@ -1209,10 +1209,11 @@ TEST_CASE(
12091209 symbol_exprt{" foo" , make_type (8 )},
12101210 symbol_exprt{" bar" , make_type (32 )});
12111211 INFO (" Input expr: " + input.pretty (2 , 0 ));
1212- const smt_termt expected_result = make_shift_term (
1213- make_extension (24 )(
1214- smt_identifier_termt{" foo" , smt_bit_vector_sortt{8 }}),
1215- smt_identifier_termt{" bar" , smt_bit_vector_sortt{32 }});
1212+ const smt_termt expected_result =
1213+ smt_bit_vector_theoryt::extract (7 , 0 )(make_shift_term (
1214+ make_extension (24 )(
1215+ smt_identifier_termt{" foo" , smt_bit_vector_sortt{8 }}),
1216+ smt_identifier_termt{" bar" , smt_bit_vector_sortt{32 }}));
12161217 CHECK (test.convert (input) == expected_result);
12171218 }
12181219 }
You can’t perform that action at this time.
0 commit comments