@@ -573,7 +573,10 @@ void dump_ct::convert_compound(
573
573
typet comp_type_to_use = comp.type ();
574
574
if (is_anon)
575
575
{
576
- comp_type_to_use = ns.follow (comp.type ());
576
+ comp_type_to_use =
577
+ (comp.type ().id () == ID_struct_tag || comp.type ().id () == ID_union_tag)
578
+ ? ns.follow_tag (to_struct_or_union_tag_type (comp.type ()))
579
+ : comp.type ();
577
580
comp_type_to_use.remove (ID_tag);
578
581
if (
579
582
recursive && (comp_type_to_use.id () == ID_struct ||
@@ -1353,8 +1356,9 @@ void dump_ct::cleanup_expr(exprt &expr)
1353
1356
1354
1357
if (expr.id ()==ID_struct)
1355
1358
{
1356
- struct_typet type=
1357
- to_struct_type (ns.follow (expr.type ()));
1359
+ struct_typet type = expr.type ().id () == ID_struct_tag
1360
+ ? ns.follow_tag (to_struct_tag_type (expr.type ()))
1361
+ : to_struct_type (expr.type ());
1358
1362
1359
1363
struct_union_typet::componentst old_components;
1360
1364
old_components.swap (type.components ());
@@ -1382,7 +1386,9 @@ void dump_ct::cleanup_expr(exprt &expr)
1382
1386
else if (expr.id ()==ID_union)
1383
1387
{
1384
1388
union_exprt &u=to_union_expr (expr);
1385
- const union_typet &u_type_f=to_union_type (ns.follow (u.type ()));
1389
+ const union_typet &u_type_f = u.type ().id () == ID_union_tag
1390
+ ? ns.follow_tag (to_union_tag_type (u.type ()))
1391
+ : to_union_type (u.type ());
1386
1392
1387
1393
if (!u.type ().get_bool (ID_C_transparent_union) &&
1388
1394
!u_type_f.get_bool (ID_C_transparent_union))
@@ -1440,7 +1446,10 @@ void dump_ct::cleanup_expr(exprt &expr)
1440
1446
code_typet::parameterst::const_iterator it=parameters.begin ();
1441
1447
for (auto &argument : arguments)
1442
1448
{
1443
- const typet &type=ns.follow (it->type ());
1449
+ const typet &type = it->type ().id () == ID_union_tag
1450
+ ? static_cast <const typet &>(ns.follow_tag (
1451
+ to_union_tag_type (it->type ())))
1452
+ : it->type ();
1444
1453
if (type.id ()==ID_union &&
1445
1454
type.get_bool (ID_C_transparent_union))
1446
1455
{
@@ -1494,7 +1503,9 @@ void dump_ct::cleanup_expr(exprt &expr)
1494
1503
{
1495
1504
const union_exprt &union_expr = to_union_expr (bu.op ());
1496
1505
const union_typet &union_type =
1497
- to_union_type (ns.follow (union_expr.type ()));
1506
+ union_expr.type ().id () == ID_union_tag
1507
+ ? ns.follow_tag (to_union_tag_type (union_expr.type ()))
1508
+ : to_union_type (union_expr.type ());
1498
1509
1499
1510
for (const auto &comp : union_type.components ())
1500
1511
{
@@ -1524,9 +1535,14 @@ void dump_ct::cleanup_expr(exprt &expr)
1524
1535
else if (
1525
1536
bu.op ().id () == ID_side_effect &&
1526
1537
to_side_effect_expr (bu.op ()).get_statement () == ID_nondet &&
1527
- ns.follow (bu.op ().type ()).id () == ID_union && bu.offset ().is_zero ())
1538
+ (bu.op ().type ().id () == ID_union ||
1539
+ bu.op ().type ().id () == ID_union_tag) &&
1540
+ bu.offset ().is_zero ())
1528
1541
{
1529
- const union_typet &union_type = to_union_type (ns.follow (bu.op ().type ()));
1542
+ const union_typet &union_type =
1543
+ bu.op ().type ().id () == ID_union_tag
1544
+ ? ns.follow_tag (to_union_tag_type (bu.op ().type ()))
1545
+ : to_union_type (bu.op ().type ());
1530
1546
1531
1547
for (const auto &comp : union_type.components ())
1532
1548
{
@@ -1542,7 +1558,7 @@ void dump_ct::cleanup_expr(exprt &expr)
1542
1558
1543
1559
std::optional<exprt> clean_init;
1544
1560
if (
1545
- ns. follow (bu.type ()) .id () == ID_union &&
1561
+ (bu.type ().id () == ID_union || bu. type (). id () == ID_union_tag) &&
1546
1562
bu.source_location ().get_function ().empty ())
1547
1563
{
1548
1564
clean_init = zero_initializer (bu.op ().type (), source_locationt{}, ns)
@@ -1553,7 +1569,10 @@ void dump_ct::cleanup_expr(exprt &expr)
1553
1569
1554
1570
if (clean_init.has_value () && bu.op () == *clean_init)
1555
1571
{
1556
- const union_typet &union_type = to_union_type (ns.follow (bu.type ()));
1572
+ const union_typet &union_type =
1573
+ bu.type ().id () == ID_union_tag
1574
+ ? ns.follow_tag (to_union_tag_type (bu.type ()))
1575
+ : to_union_type (bu.type ());
1557
1576
1558
1577
for (const auto &comp : union_type.components ())
1559
1578
{
0 commit comments