@@ -846,7 +846,10 @@ void smt2_convt::convert_address_of_rec(
846846 struct_op_type.id () == ID_struct || struct_op_type.id () == ID_struct_tag,
847847 " member expression operand shall have struct type" );
848848
849- const struct_typet &struct_type = to_struct_type (ns.follow (struct_op_type));
849+ const struct_typet &struct_type =
850+ struct_op_type.id () == ID_struct_tag
851+ ? ns.follow_tag (to_struct_tag_type (struct_op_type))
852+ : to_struct_type (struct_op_type);
850853
851854 const irep_idt &component_name = member_expr.get_component_name ();
852855
@@ -3167,7 +3170,10 @@ void smt2_convt::convert_floatbv_typecast(const floatbv_typecast_exprt &expr)
31673170
31683171void smt2_convt::convert_struct (const struct_exprt &expr)
31693172{
3170- const struct_typet &struct_type = to_struct_type (ns.follow (expr.type ()));
3173+ const struct_typet &struct_type =
3174+ expr.type ().id () == ID_struct_tag
3175+ ? ns.follow_tag (to_struct_tag_type (expr.type ()))
3176+ : to_struct_type (expr.type ());
31713177
31723178 const struct_typet::componentst &components=
31733179 struct_type.components ();
@@ -3270,10 +3276,9 @@ void smt2_convt::flatten_array(const exprt &expr)
32703276
32713277void smt2_convt::convert_union (const union_exprt &expr)
32723278{
3273- const union_typet &union_type = to_union_type (ns.follow (expr.type ()));
32743279 const exprt &op=expr.op ();
32753280
3276- std::size_t total_width= boolbv_width (union_type );
3281+ std::size_t total_width = boolbv_width (expr. type () );
32773282
32783283 std::size_t member_width=boolbv_width (op.type ());
32793284
@@ -4190,7 +4195,10 @@ void smt2_convt::convert_with(const with_exprt &expr)
41904195 }
41914196 else if (expr_type.id () == ID_struct || expr_type.id () == ID_struct_tag)
41924197 {
4193- const struct_typet &struct_type = to_struct_type (ns.follow (expr_type));
4198+ const struct_typet &struct_type =
4199+ expr_type.id () == ID_struct_tag
4200+ ? ns.follow_tag (to_struct_tag_type (expr_type))
4201+ : to_struct_type (expr_type);
41944202
41954203 const exprt &index = expr.where ();
41964204 const exprt &value = expr.new_value ();
@@ -4261,11 +4269,9 @@ void smt2_convt::convert_with(const with_exprt &expr)
42614269 }
42624270 else if (expr_type.id () == ID_union || expr_type.id () == ID_union_tag)
42634271 {
4264- const union_typet &union_type = to_union_type (ns.follow (expr_type));
4265-
42664272 const exprt &value = expr.new_value ();
42674273
4268- std::size_t total_width= boolbv_width (union_type );
4274+ std::size_t total_width = boolbv_width (expr_type );
42694275
42704276 std::size_t member_width=boolbv_width (value.type ());
42714277
@@ -4407,7 +4413,10 @@ void smt2_convt::convert_member(const member_exprt &expr)
44074413
44084414 if (struct_op_type.id () == ID_struct || struct_op_type.id () == ID_struct_tag)
44094415 {
4410- const struct_typet &struct_type = to_struct_type (ns.follow (struct_op_type));
4416+ const struct_typet &struct_type =
4417+ struct_op_type.id () == ID_struct_tag
4418+ ? ns.follow_tag (to_struct_tag_type (struct_op_type))
4419+ : to_struct_type (struct_op_type);
44114420
44124421 INVARIANT (
44134422 struct_type.has_component (name), " struct should have accessed component" );
@@ -4504,7 +4513,9 @@ void smt2_convt::flatten2bv(const exprt &expr)
45044513 if (use_datatypes)
45054514 {
45064515 // concatenate elements
4507- const struct_typet &struct_type = to_struct_type (ns.follow (type));
4516+ const struct_typet &struct_type =
4517+ type.id () == ID_struct_tag ? ns.follow_tag (to_struct_tag_type (type))
4518+ : to_struct_type (type);
45084519
45094520 const struct_typet::componentst &components=
45104521 struct_type.components ();
@@ -4630,7 +4641,9 @@ void smt2_convt::unflatten(
46304641
46314642 out << " (mk-" << smt_typename;
46324643
4633- const struct_typet &struct_type = to_struct_type (ns.follow (type));
4644+ const struct_typet &struct_type =
4645+ type.id () == ID_struct_tag ? ns.follow_tag (to_struct_tag_type (type))
4646+ : to_struct_type (type);
46344647
46354648 const struct_typet::componentst &components=
46364649 struct_type.components ();
@@ -5509,8 +5522,11 @@ void smt2_convt::convert_type(const typet &type)
55095522 else if (type.id () == ID_union || type.id () == ID_union_tag)
55105523 {
55115524 std::size_t width=boolbv_width (type);
5525+ const union_typet &union_type = type.id () == ID_union_tag
5526+ ? ns.follow_tag (to_union_tag_type (type))
5527+ : to_union_type (type);
55125528 CHECK_RETURN_WITH_DIAGNOSTICS (
5513- to_union_type (ns. follow (type)) .components ().empty () || width != 0 ,
5529+ union_type .components ().empty () || width != 0 ,
55145530 " failed to get width of union" );
55155531
55165532 out << " (_ BitVec " << width << " )" ;
0 commit comments