Skip to content

Commit 837c8e3

Browse files
committed
Support non-tag typed struct/union member expressions
The SAT back-end assumed that all struct/union expressions had a tag instead of the full type, which is not actually a GOTO program invariant.
1 parent 15d60af commit 837c8e3

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/solvers/flattening/boolbv_member.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,14 @@ bvt boolbvt::convert_member(const member_exprt &expr)
4747
{
4848
const bvt &compound_bv = convert_bv(expr.compound());
4949

50-
if(expr.compound().type().id() == ID_struct_tag)
50+
const typet &compound_type = expr.compound().type();
51+
52+
if(compound_type.id() == ID_struct_tag || compound_type.id() == ID_struct)
5153
{
5254
const struct_typet &struct_op_type =
53-
ns.follow_tag(to_struct_tag_type(expr.compound().type()));
55+
compound_type.id() == ID_struct_tag
56+
? ns.follow_tag(to_struct_tag_type(compound_type))
57+
: to_struct_type(compound_type);
5458

5559
const auto &member_bits =
5660
bv_width.get_member(struct_op_type, expr.get_component_name());
@@ -66,7 +70,8 @@ bvt boolbvt::convert_member(const member_exprt &expr)
6670
}
6771
else
6872
{
69-
PRECONDITION(expr.compound().type().id() == ID_union_tag);
73+
PRECONDITION(
74+
compound_type.id() == ID_union_tag || compound_type.id() == ID_union);
7075
return convert_member_union(expr, compound_bv, *this, ns);
7176
}
7277
}

0 commit comments

Comments
 (0)