@@ -556,10 +556,10 @@ void smt2_convt::convert_address_of_rec(
556
556
const typet &struct_op_type=ns.follow (struct_op.type ());
557
557
558
558
DATA_INVARIANT (
559
- struct_op_type.id () == ID_struct,
559
+ struct_op_type.id () == ID_struct || struct_op_type. id () == ID_struct_tag ,
560
560
" member expression operand shall have struct type" );
561
561
562
- const struct_typet &struct_type = to_struct_type (struct_op_type);
562
+ const struct_typet &struct_type = to_struct_type (ns. follow ( struct_op_type) );
563
563
564
564
const irep_idt &component_name = member_expr.get_component_name ();
565
565
@@ -2140,7 +2140,9 @@ void smt2_convt::convert_typecast(const typecast_exprt &expr)
2140
2140
else
2141
2141
SMT2_TODO (" can't convert non-constant integer to bitvector" );
2142
2142
}
2143
- else if (src_type.id ()==ID_struct) // flatten a struct to a bit-vector
2143
+ else if (
2144
+ src_type.id () == ID_struct ||
2145
+ src_type.id () == ID_struct_tag) // flatten a struct to a bit-vector
2144
2146
{
2145
2147
if (use_datatypes)
2146
2148
{
@@ -2157,7 +2159,9 @@ void smt2_convt::convert_typecast(const typecast_exprt &expr)
2157
2159
convert_expr (src); // nothing else to do!
2158
2160
}
2159
2161
}
2160
- else if (src_type.id ()==ID_union) // flatten a union
2162
+ else if (
2163
+ src_type.id () == ID_union ||
2164
+ src_type.id () == ID_union_tag) // flatten a union
2161
2165
{
2162
2166
INVARIANT (
2163
2167
boolbv_width (src_type) == boolbv_width (dest_type),
@@ -2570,7 +2574,7 @@ void smt2_convt::convert_floatbv_typecast(const floatbv_typecast_exprt &expr)
2570
2574
2571
2575
void smt2_convt::convert_struct (const struct_exprt &expr)
2572
2576
{
2573
- const struct_typet &struct_type= to_struct_type (expr.type ());
2577
+ const struct_typet &struct_type = to_struct_type (ns. follow ( expr.type () ));
2574
2578
2575
2579
const struct_typet::componentst &components=
2576
2580
struct_type.components ();
@@ -2664,7 +2668,7 @@ void smt2_convt::flatten_array(const exprt &expr)
2664
2668
2665
2669
void smt2_convt::convert_union (const union_exprt &expr)
2666
2670
{
2667
- const union_typet &union_type= to_union_type (expr.type ());
2671
+ const union_typet &union_type = to_union_type (ns. follow ( expr.type () ));
2668
2672
const exprt &op=expr.op ();
2669
2673
2670
2674
boolbv_widtht boolbv_width (ns);
@@ -3551,9 +3555,9 @@ void smt2_convt::convert_with(const with_exprt &expr)
3551
3555
out << " ) distance?)))" ; // zero_extend, bvlshr, bvor, let
3552
3556
}
3553
3557
}
3554
- else if (expr_type.id ()== ID_struct)
3558
+ else if (expr_type.id () == ID_struct || expr_type. id () == ID_struct_tag )
3555
3559
{
3556
- const struct_typet &struct_type= to_struct_type (expr_type);
3560
+ const struct_typet &struct_type = to_struct_type (ns. follow ( expr_type) );
3557
3561
3558
3562
const exprt &index =expr.op1 ();
3559
3563
const exprt &value=expr.op2 ();
@@ -3621,9 +3625,9 @@ void smt2_convt::convert_with(const with_exprt &expr)
3621
3625
out << " )" ; // let ?withop
3622
3626
}
3623
3627
}
3624
- else if (expr_type.id ()== ID_union)
3628
+ else if (expr_type.id () == ID_union || expr_type. id () == ID_union_tag )
3625
3629
{
3626
- const union_typet &union_type= to_union_type (expr_type);
3630
+ const union_typet &union_type = to_union_type (ns. follow ( expr_type) );
3627
3631
3628
3632
const exprt &value=expr.op2 ();
3629
3633
@@ -3827,10 +3831,9 @@ void smt2_convt::convert_member(const member_exprt &expr)
3827
3831
const typet &struct_op_type=ns.follow (struct_op.type ());
3828
3832
const irep_idt &name=member_expr.get_component_name ();
3829
3833
3830
- if (struct_op_type.id ()== ID_struct)
3834
+ if (struct_op_type.id () == ID_struct || struct_op_type. id () == ID_struct_tag )
3831
3835
{
3832
- const struct_typet &struct_type=
3833
- to_struct_type (struct_op_type);
3836
+ const struct_typet &struct_type = to_struct_type (ns.follow (struct_op_type));
3834
3837
3835
3838
INVARIANT (
3836
3839
struct_type.has_component (name), " struct should have accessed component" );
@@ -3860,7 +3863,8 @@ void smt2_convt::convert_member(const member_exprt &expr)
3860
3863
out << " )" ;
3861
3864
}
3862
3865
}
3863
- else if (struct_op_type.id ()==ID_union)
3866
+ else if (
3867
+ struct_op_type.id () == ID_union || struct_op_type.id () == ID_union_tag)
3864
3868
{
3865
3869
std::size_t width=boolbv_width (expr.type ());
3866
3870
CHECK_RETURN_WITH_DIAGNOSTICS (
@@ -3922,14 +3926,14 @@ void smt2_convt::flatten2bv(const exprt &expr)
3922
3926
{
3923
3927
convert_expr (expr);
3924
3928
}
3925
- else if (type.id ()== ID_struct)
3929
+ else if (type.id () == ID_struct || type. id () == ID_struct_tag )
3926
3930
{
3927
3931
if (use_datatypes)
3928
3932
{
3929
3933
const std::string &smt_typename = datatype_map.at (type);
3930
3934
3931
3935
// concatenate elements
3932
- const struct_typet &struct_type= to_struct_type (type);
3936
+ const struct_typet &struct_type = to_struct_type (ns. follow ( type) );
3933
3937
3934
3938
out << " (let ((?sflop " ;
3935
3939
convert_expr (expr);
@@ -4025,7 +4029,7 @@ void smt2_convt::unflatten(
4025
4029
// nop, already a bv
4026
4030
}
4027
4031
}
4028
- else if (type.id ()== ID_struct)
4032
+ else if (type.id () == ID_struct || type. id () == ID_struct_tag )
4029
4033
{
4030
4034
if (use_datatypes)
4031
4035
{
@@ -4040,7 +4044,7 @@ void smt2_convt::unflatten(
4040
4044
4041
4045
out << " (mk-" << smt_typename;
4042
4046
4043
- const struct_typet &struct_type= to_struct_type (type);
4047
+ const struct_typet &struct_type = to_struct_type (ns. follow ( type) );
4044
4048
4045
4049
const struct_typet::componentst &components=
4046
4050
struct_type.components ();
@@ -4411,7 +4415,7 @@ void smt2_convt::convert_type(const typet &type)
4411
4415
{
4412
4416
out << " Bool" ;
4413
4417
}
4414
- else if (type.id ()== ID_struct)
4418
+ else if (type.id () == ID_struct || type. id () == ID_struct_tag )
4415
4419
{
4416
4420
if (use_datatypes)
4417
4421
{
@@ -4450,7 +4454,7 @@ void smt2_convt::convert_type(const typet &type)
4450
4454
// member count.
4451
4455
out << " Bool" ;
4452
4456
}
4453
- else if (type.id ()== ID_union)
4457
+ else if (type.id () == ID_union || type. id () == ID_union_tag )
4454
4458
{
4455
4459
boolbv_widtht boolbv_width (ns);
4456
4460
@@ -4602,7 +4606,7 @@ void smt2_convt::find_symbols_rec(
4602
4606
out << " ))))\n " ;
4603
4607
}
4604
4608
}
4605
- else if (type.id ()== ID_struct)
4609
+ else if (type.id () == ID_struct)
4606
4610
{
4607
4611
// Cater for mutually recursive struct types
4608
4612
bool need_decl=false ;
@@ -4615,11 +4619,11 @@ void smt2_convt::find_symbols_rec(
4615
4619
need_decl=true ;
4616
4620
}
4617
4621
4618
- const struct_typet::componentst &components=
4622
+ const struct_typet::componentst &components =
4619
4623
to_struct_type (type).components ();
4620
4624
4621
- for (const auto &component : components)
4622
- find_symbols_rec (component.type (), recstack);
4625
+ for (const auto &component : components)
4626
+ find_symbols_rec (component.type (), recstack);
4623
4627
4624
4628
// Declare the corresponding SMT type if we haven't already.
4625
4629
if (need_decl)
@@ -4698,9 +4702,9 @@ void smt2_convt::find_symbols_rec(
4698
4702
out << " \n " ;
4699
4703
}
4700
4704
}
4701
- else if (type.id ()== ID_union)
4705
+ else if (type.id () == ID_union)
4702
4706
{
4703
- const union_typet::componentst &components=
4707
+ const union_typet::componentst &components =
4704
4708
to_union_type (type).components ();
4705
4709
4706
4710
for (const auto &component : components)
@@ -4730,6 +4734,28 @@ void smt2_convt::find_symbols_rec(
4730
4734
find_symbols_rec (ns.follow (type), recstack);
4731
4735
}
4732
4736
}
4737
+ else if (type.id () == ID_struct_tag)
4738
+ {
4739
+ const auto &struct_tag = to_struct_tag_type (type);
4740
+ const irep_idt &id = struct_tag.get_identifier ();
4741
+
4742
+ if (recstack.find (id) == recstack.end ())
4743
+ {
4744
+ recstack.insert (id);
4745
+ find_symbols_rec (ns.follow_tag (struct_tag), recstack);
4746
+ }
4747
+ }
4748
+ else if (type.id () == ID_union_tag)
4749
+ {
4750
+ const auto &union_tag = to_union_tag_type (type);
4751
+ const irep_idt &id = union_tag.get_identifier ();
4752
+
4753
+ if (recstack.find (id) == recstack.end ())
4754
+ {
4755
+ recstack.insert (id);
4756
+ find_symbols_rec (ns.follow_tag (union_tag), recstack);
4757
+ }
4758
+ }
4733
4759
}
4734
4760
4735
4761
exprt smt2_convt::letify (exprt &expr)
0 commit comments