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)
164
164
return smt_bit_vector_theoryt::sign_extend;
165
165
if (can_cast_type<unsignedbv_typet>(type))
166
166
return smt_bit_vector_theoryt::zero_extend;
167
+ if (can_cast_type<bv_typet>(type))
168
+ return smt_bit_vector_theoryt::zero_extend;
167
169
UNREACHABLE;
168
170
}
169
171
@@ -947,6 +949,9 @@ static smt_termt convert_to_smt_shift(
947
949
INVARIANT (
948
950
first_bit_vector_sort && second_bit_vector_sort,
949
951
" 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." );
950
955
const std::size_t first_width = first_bit_vector_sort->bit_width ();
951
956
const std::size_t second_width = second_bit_vector_sort->bit_width ();
952
957
if (first_width > second_width)
@@ -958,10 +963,11 @@ static smt_termt convert_to_smt_shift(
958
963
}
959
964
else if (first_width < second_width)
960
965
{
961
- return factory (
966
+ const auto result = factory (
962
967
extension_for_type (shift.op0 ().type ())(second_width - first_width)(
963
968
first_operand),
964
969
second_operand);
970
+ return smt_bit_vector_theoryt::extract (first_width - 1 , 0 )(result);
965
971
}
966
972
else
967
973
{
Original file line number Diff line number Diff line change @@ -1209,10 +1209,11 @@ TEST_CASE(
1209
1209
symbol_exprt{" foo" , make_type (8 )},
1210
1210
symbol_exprt{" bar" , make_type (32 )});
1211
1211
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 }}));
1216
1217
CHECK (test.convert (input) == expected_result);
1217
1218
}
1218
1219
}
You can’t perform that action at this time.
0 commit comments