@@ -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);
@@ -3552,9 +3556,9 @@ void smt2_convt::convert_with(const with_exprt &expr)
3552
3556
out << " ) distance?)))" ; // zero_extend, bvshl, bvor, let
3553
3557
}
3554
3558
}
3555
- else if (expr_type.id ()== ID_struct)
3559
+ else if (expr_type.id () == ID_struct || expr_type. id () == ID_struct_tag )
3556
3560
{
3557
- const struct_typet &struct_type= to_struct_type (expr_type);
3561
+ const struct_typet &struct_type = to_struct_type (ns. follow ( expr_type) );
3558
3562
3559
3563
const exprt &index =expr.op1 ();
3560
3564
const exprt &value=expr.op2 ();
@@ -3623,9 +3627,9 @@ void smt2_convt::convert_with(const with_exprt &expr)
3623
3627
out << " )" ; // let ?withop
3624
3628
}
3625
3629
}
3626
- else if (expr_type.id ()== ID_union)
3630
+ else if (expr_type.id () == ID_union || expr_type. id () == ID_union_tag )
3627
3631
{
3628
- const union_typet &union_type= to_union_type (expr_type);
3632
+ const union_typet &union_type = to_union_type (ns. follow ( expr_type) );
3629
3633
3630
3634
const exprt &value=expr.op2 ();
3631
3635
@@ -3829,10 +3833,9 @@ void smt2_convt::convert_member(const member_exprt &expr)
3829
3833
const typet &struct_op_type=ns.follow (struct_op.type ());
3830
3834
const irep_idt &name=member_expr.get_component_name ();
3831
3835
3832
- if (struct_op_type.id ()== ID_struct)
3836
+ if (struct_op_type.id () == ID_struct || struct_op_type. id () == ID_struct_tag )
3833
3837
{
3834
- const struct_typet &struct_type=
3835
- to_struct_type (struct_op_type);
3838
+ const struct_typet &struct_type = to_struct_type (ns.follow (struct_op_type));
3836
3839
3837
3840
INVARIANT (
3838
3841
struct_type.has_component (name), " struct should have accessed component" );
@@ -3862,7 +3865,8 @@ void smt2_convt::convert_member(const member_exprt &expr)
3862
3865
out << " )" ;
3863
3866
}
3864
3867
}
3865
- else if (struct_op_type.id ()==ID_union)
3868
+ else if (
3869
+ struct_op_type.id () == ID_union || struct_op_type.id () == ID_union_tag)
3866
3870
{
3867
3871
std::size_t width=boolbv_width (expr.type ());
3868
3872
CHECK_RETURN_WITH_DIAGNOSTICS (
@@ -3924,14 +3928,14 @@ void smt2_convt::flatten2bv(const exprt &expr)
3924
3928
{
3925
3929
convert_expr (expr);
3926
3930
}
3927
- else if (type.id ()== ID_struct)
3931
+ else if (type.id () == ID_struct || type. id () == ID_struct_tag )
3928
3932
{
3929
3933
if (use_datatypes)
3930
3934
{
3931
3935
const std::string &smt_typename = datatype_map.at (type);
3932
3936
3933
3937
// concatenate elements
3934
- const struct_typet &struct_type= to_struct_type (type);
3938
+ const struct_typet &struct_type = to_struct_type (ns. follow ( type) );
3935
3939
3936
3940
out << " (let ((?sflop " ;
3937
3941
convert_expr (expr);
@@ -4027,7 +4031,7 @@ void smt2_convt::unflatten(
4027
4031
// nop, already a bv
4028
4032
}
4029
4033
}
4030
- else if (type.id ()== ID_struct)
4034
+ else if (type.id () == ID_struct || type. id () == ID_struct_tag )
4031
4035
{
4032
4036
if (use_datatypes)
4033
4037
{
@@ -4042,7 +4046,7 @@ void smt2_convt::unflatten(
4042
4046
4043
4047
out << " (mk-" << smt_typename;
4044
4048
4045
- const struct_typet &struct_type= to_struct_type (type);
4049
+ const struct_typet &struct_type = to_struct_type (ns. follow ( type) );
4046
4050
4047
4051
const struct_typet::componentst &components=
4048
4052
struct_type.components ();
@@ -4426,7 +4430,7 @@ void smt2_convt::convert_type(const typet &type)
4426
4430
{
4427
4431
out << " Bool" ;
4428
4432
}
4429
- else if (type.id ()== ID_struct)
4433
+ else if (type.id () == ID_struct || type. id () == ID_struct_tag )
4430
4434
{
4431
4435
if (use_datatypes)
4432
4436
{
@@ -4465,7 +4469,7 @@ void smt2_convt::convert_type(const typet &type)
4465
4469
// member count.
4466
4470
out << " Bool" ;
4467
4471
}
4468
- else if (type.id ()== ID_union)
4472
+ else if (type.id () == ID_union || type. id () == ID_union_tag )
4469
4473
{
4470
4474
boolbv_widtht boolbv_width (ns);
4471
4475
@@ -4617,7 +4621,7 @@ void smt2_convt::find_symbols_rec(
4617
4621
out << " ))))\n " ;
4618
4622
}
4619
4623
}
4620
- else if (type.id ()== ID_struct)
4624
+ else if (type.id () == ID_struct)
4621
4625
{
4622
4626
// Cater for mutually recursive struct types
4623
4627
bool need_decl=false ;
@@ -4630,11 +4634,11 @@ void smt2_convt::find_symbols_rec(
4630
4634
need_decl=true ;
4631
4635
}
4632
4636
4633
- const struct_typet::componentst &components=
4637
+ const struct_typet::componentst &components =
4634
4638
to_struct_type (type).components ();
4635
4639
4636
- for (const auto &component : components)
4637
- find_symbols_rec (component.type (), recstack);
4640
+ for (const auto &component : components)
4641
+ find_symbols_rec (component.type (), recstack);
4638
4642
4639
4643
// Declare the corresponding SMT type if we haven't already.
4640
4644
if (need_decl)
@@ -4713,9 +4717,9 @@ void smt2_convt::find_symbols_rec(
4713
4717
out << " \n " ;
4714
4718
}
4715
4719
}
4716
- else if (type.id ()== ID_union)
4720
+ else if (type.id () == ID_union)
4717
4721
{
4718
- const union_typet::componentst &components=
4722
+ const union_typet::componentst &components =
4719
4723
to_union_type (type).components ();
4720
4724
4721
4725
for (const auto &component : components)
@@ -4745,6 +4749,28 @@ void smt2_convt::find_symbols_rec(
4745
4749
find_symbols_rec (ns.follow (type), recstack);
4746
4750
}
4747
4751
}
4752
+ else if (type.id () == ID_struct_tag)
4753
+ {
4754
+ const auto &struct_tag = to_struct_tag_type (type);
4755
+ const irep_idt &id = struct_tag.get_identifier ();
4756
+
4757
+ if (recstack.find (id) == recstack.end ())
4758
+ {
4759
+ recstack.insert (id);
4760
+ find_symbols_rec (ns.follow_tag (struct_tag), recstack);
4761
+ }
4762
+ }
4763
+ else if (type.id () == ID_union_tag)
4764
+ {
4765
+ const auto &union_tag = to_union_tag_type (type);
4766
+ const irep_idt &id = union_tag.get_identifier ();
4767
+
4768
+ if (recstack.find (id) == recstack.end ())
4769
+ {
4770
+ recstack.insert (id);
4771
+ find_symbols_rec (ns.follow_tag (union_tag), recstack);
4772
+ }
4773
+ }
4748
4774
}
4749
4775
4750
4776
exprt smt2_convt::letify (exprt &expr)
0 commit comments