@@ -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
@@ -3159,7 +3162,10 @@ void smt2_convt::convert_floatbv_typecast(const floatbv_typecast_exprt &expr)
31593162
31603163void smt2_convt::convert_struct (const struct_exprt &expr)
31613164{
3162- const struct_typet &struct_type = to_struct_type (ns.follow (expr.type ()));
3165+ const struct_typet &struct_type =
3166+ expr.type ().id () == ID_struct_tag
3167+ ? ns.follow_tag (to_struct_tag_type (expr.type ()))
3168+ : to_struct_type (expr.type ());
31633169
31643170 const struct_typet::componentst &components=
31653171 struct_type.components ();
@@ -3262,10 +3268,9 @@ void smt2_convt::flatten_array(const exprt &expr)
32623268
32633269void smt2_convt::convert_union (const union_exprt &expr)
32643270{
3265- const union_typet &union_type = to_union_type (ns.follow (expr.type ()));
32663271 const exprt &op=expr.op ();
32673272
3268- std::size_t total_width= boolbv_width (union_type );
3273+ std::size_t total_width = boolbv_width (expr. type () );
32693274
32703275 std::size_t member_width=boolbv_width (op.type ());
32713276
@@ -4182,7 +4187,10 @@ void smt2_convt::convert_with(const with_exprt &expr)
41824187 }
41834188 else if (expr_type.id () == ID_struct || expr_type.id () == ID_struct_tag)
41844189 {
4185- const struct_typet &struct_type = to_struct_type (ns.follow (expr_type));
4190+ const struct_typet &struct_type =
4191+ expr_type.id () == ID_struct_tag
4192+ ? ns.follow_tag (to_struct_tag_type (expr_type))
4193+ : to_struct_type (expr_type);
41864194
41874195 const exprt &index = expr.where ();
41884196 const exprt &value = expr.new_value ();
@@ -4253,11 +4261,9 @@ void smt2_convt::convert_with(const with_exprt &expr)
42534261 }
42544262 else if (expr_type.id () == ID_union || expr_type.id () == ID_union_tag)
42554263 {
4256- const union_typet &union_type = to_union_type (ns.follow (expr_type));
4257-
42584264 const exprt &value = expr.new_value ();
42594265
4260- std::size_t total_width= boolbv_width (union_type );
4266+ std::size_t total_width = boolbv_width (expr_type );
42614267
42624268 std::size_t member_width=boolbv_width (value.type ());
42634269
@@ -4399,7 +4405,10 @@ void smt2_convt::convert_member(const member_exprt &expr)
43994405
44004406 if (struct_op_type.id () == ID_struct || struct_op_type.id () == ID_struct_tag)
44014407 {
4402- const struct_typet &struct_type = to_struct_type (ns.follow (struct_op_type));
4408+ const struct_typet &struct_type =
4409+ struct_op_type.id () == ID_struct_tag
4410+ ? ns.follow_tag (to_struct_tag_type (struct_op_type))
4411+ : to_struct_type (struct_op_type);
44034412
44044413 INVARIANT (
44054414 struct_type.has_component (name), " struct should have accessed component" );
@@ -4496,7 +4505,9 @@ void smt2_convt::flatten2bv(const exprt &expr)
44964505 if (use_datatypes)
44974506 {
44984507 // concatenate elements
4499- const struct_typet &struct_type = to_struct_type (ns.follow (type));
4508+ const struct_typet &struct_type =
4509+ type.id () == ID_struct_tag ? ns.follow_tag (to_struct_tag_type (type))
4510+ : to_struct_type (type);
45004511
45014512 const struct_typet::componentst &components=
45024513 struct_type.components ();
@@ -4622,7 +4633,9 @@ void smt2_convt::unflatten(
46224633
46234634 out << " (mk-" << smt_typename;
46244635
4625- const struct_typet &struct_type = to_struct_type (ns.follow (type));
4636+ const struct_typet &struct_type =
4637+ type.id () == ID_struct_tag ? ns.follow_tag (to_struct_tag_type (type))
4638+ : to_struct_type (type);
46264639
46274640 const struct_typet::componentst &components=
46284641 struct_type.components ();
@@ -5501,8 +5514,11 @@ void smt2_convt::convert_type(const typet &type)
55015514 else if (type.id () == ID_union || type.id () == ID_union_tag)
55025515 {
55035516 std::size_t width=boolbv_width (type);
5517+ const union_typet &union_type = type.id () == ID_union_tag
5518+ ? ns.follow_tag (to_union_tag_type (type))
5519+ : to_union_type (type);
55045520 CHECK_RETURN_WITH_DIAGNOSTICS (
5505- to_union_type (ns. follow (type)) .components ().empty () || width != 0 ,
5521+ union_type .components ().empty () || width != 0 ,
55065522 " failed to get width of union" );
55075523
55085524 out << " (_ BitVec " << width << " )" ;
0 commit comments