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