Skip to content

byte_extract lowering: ensure type consistency [blocks: #2068] #4063

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion regression/cbmc/Pointer_byte_extract3/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
CORE broken-smt-backend
main.c

^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/cbmc/Pointer_byte_extract7/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
CORE broken-smt-backend
main.c
--big-endian
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/cbmc/equality_through_union1/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
CORE broken-smt-backend
main.c

^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/cbmc/equality_through_union2/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
CORE broken-smt-backend
main.c

^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/cbmc/equality_through_union3/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
CORE broken-smt-backend
main.c

^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/cbmc/gcc_vector1/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
CORE broken-smt-backend
main.c

^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/cbmc/trace_address_arithmetic1/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
CORE broken-smt-backend
main.c
--trace
^EXIT=10$
Expand Down
2 changes: 1 addition & 1 deletion regression/cbmc/union11/union_list.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
CORE broken-smt-backend
union_list.c

^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/cbmc/union8/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CORE
CORE broken-smt-backend
main.c

^EXIT=0$
Expand Down
6 changes: 4 additions & 2 deletions src/solvers/lowering/byte_operators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,10 @@ exprt lower_byte_extract(const byte_extract_exprt &src, const namespacet &ns)
return simplify_expr(typecast_exprt(op.front(), src.type()), ns);
else // width_bytes>=2
{
concatenation_exprt concatenation(std::move(op), src.type());
return simplify_expr(concatenation, ns);
concatenation_exprt concatenation(
std::move(op), bitvector_typet(subtype.id(), width_bytes * 8));
return simplify_expr(
typecast_exprt(std::move(concatenation), src.type()), ns);
}
}

Expand Down
14 changes: 6 additions & 8 deletions unit/solvers/lowering/byte_operators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ SCENARIO("byte_extract_lowering", "[core][solvers][lowering][byte_extract]")
constant_exprt size = from_integer(8, size_type());

std::vector<typet> types = {
// struct_typet({{"comp1", u16}, {"comp2", u16}}),
// struct_typet({{"comp1", u32}, {"comp2", u64}}),
struct_typet({{"comp1", u16}, {"comp2", u16}}),
struct_typet({{"comp1", u32}, {"comp2", u64}}),
#if 0
// not currently handled: components not byte aligned
struct_typet({{"comp1", u32},
Expand All @@ -114,8 +114,8 @@ SCENARIO("byte_extract_lowering", "[core][solvers][lowering][byte_extract]")
{"comp2", u8}}),
#endif
// union_typet({{"compA", u32}, {"compB", u64}}),
// c_enum_typet(u16),
// c_enum_typet(unsignedbv_typet(128)),
c_enum_typet(u16),
c_enum_typet(unsignedbv_typet(128)),
// array_typet(u8, size),
// array_typet(s32, size),
// array_typet(u64, size),
Expand Down Expand Up @@ -193,10 +193,8 @@ SCENARIO("byte_extract_lowering", "[core][solvers][lowering][byte_extract]")
REQUIRE(!has_subexpr(lower_be, ID_byte_extract_little_endian));
REQUIRE(!has_subexpr(lower_be, ID_byte_extract_big_endian));
REQUIRE(lower_be.type() == be.type());
// TODO: does not currently hold
// REQUIRE(lower_be == r);
// TODO: does not currently hold
// REQUIRE(lower_be_s == r);
REQUIRE(lower_be == r);
REQUIRE(lower_be_s == r);
}
}
}
Expand Down