@@ -451,14 +451,13 @@ void c_typecheck_baset::typecheck_expr_main(exprt &expr)
451
451
exprt default_match=nil_exprt ();
452
452
exprt assoc_match=nil_exprt ();
453
453
454
- const typet &op_type = follow ( op.type () );
454
+ const typet &op_type = op.type ();
455
455
456
456
for (const auto &irep : generic_associations)
457
457
{
458
458
if (irep.get (ID_type_arg) == ID_default)
459
459
default_match = static_cast <const exprt &>(irep.find (ID_value));
460
- else if (
461
- op_type == follow (static_cast <const typet &>(irep.find (ID_type_arg))))
460
+ else if (op_type == static_cast <const typet &>(irep.find (ID_type_arg)))
462
461
{
463
462
assoc_match = static_cast <const exprt &>(irep.find (ID_value));
464
463
}
@@ -590,11 +589,9 @@ void c_typecheck_baset::typecheck_expr_builtin_offsetof(exprt &expr)
590
589
591
590
for (const auto &op : member.operands ())
592
591
{
593
- type = follow (type);
594
-
595
592
if (op.id () == ID_member)
596
593
{
597
- if (type.id ()!=ID_union && type.id ()!=ID_struct )
594
+ if (type.id () != ID_union_tag && type.id () != ID_struct_tag )
598
595
{
599
596
error ().source_location = expr.source_location ();
600
597
error () << " offsetof of member expects struct/union type, "
@@ -607,20 +604,20 @@ void c_typecheck_baset::typecheck_expr_builtin_offsetof(exprt &expr)
607
604
608
605
while (!found)
609
606
{
610
- PRECONDITION (type.id () == ID_union || type.id () == ID_struct );
607
+ PRECONDITION (type.id () == ID_union_tag || type.id () == ID_struct_tag );
611
608
612
- const struct_union_typet &struct_union_type=
613
- to_struct_union_type ( type);
609
+ const struct_union_typet &struct_union_type =
610
+ follow_struct_or_union_tag ( to_struct_or_union_tag_type ( type) );
614
611
615
612
// direct member?
616
613
if (struct_union_type.has_component (component_name))
617
614
{
618
615
found=true ;
619
616
620
- if (type.id ()==ID_struct )
617
+ if (type.id () == ID_struct_tag )
621
618
{
622
- auto o_opt =
623
- member_offset_expr ( to_struct_type (type), component_name, *this );
619
+ auto o_opt = member_offset_expr (
620
+ follow_tag ( to_struct_tag_type (type) ), component_name, *this );
624
621
625
622
if (!o_opt.has_value ())
626
623
{
@@ -650,10 +647,10 @@ void c_typecheck_baset::typecheck_expr_builtin_offsetof(exprt &expr)
650
647
{
651
648
if (has_component_rec (c.type (), component_name, *this ))
652
649
{
653
- if (type.id ()==ID_struct )
650
+ if (type.id () == ID_struct_tag )
654
651
{
655
652
auto o_opt = member_offset_expr (
656
- to_struct_type ( type), c.get_name (), *this );
653
+ follow_tag ( to_struct_tag_type ( type) ), c.get_name (), *this );
657
654
658
655
if (!o_opt.has_value ())
659
656
{
@@ -669,9 +666,10 @@ void c_typecheck_baset::typecheck_expr_builtin_offsetof(exprt &expr)
669
666
o_opt.value (), size_type ()));
670
667
}
671
668
672
- typet tmp = follow ( c.type () );
669
+ typet tmp = c.type ();
673
670
type=tmp;
674
- CHECK_RETURN (type.id () == ID_union || type.id () == ID_struct);
671
+ CHECK_RETURN (
672
+ type.id () == ID_union_tag || type.id () == ID_struct_tag);
675
673
found2=true ;
676
674
break ; // we run into another iteration of the outer loop
677
675
}
@@ -1377,7 +1375,7 @@ void c_typecheck_baset::typecheck_expr_rel(
1377
1375
1378
1376
if (expr.id ()==ID_equal || expr.id ()==ID_notequal)
1379
1377
{
1380
- if (follow ( o_type0)== follow ( o_type1) )
1378
+ if (o_type0 == o_type1)
1381
1379
{
1382
1380
if (o_type0.id () != ID_array)
1383
1381
{
@@ -1530,10 +1528,7 @@ void c_typecheck_baset::typecheck_expr_member(exprt &expr)
1530
1528
exprt &op0 = to_unary_expr (expr).op ();
1531
1529
typet type=op0.type ();
1532
1530
1533
- type = follow (type);
1534
-
1535
- if (type.id ()!=ID_struct &&
1536
- type.id ()!=ID_union)
1531
+ if (type.id () != ID_struct_tag && type.id () != ID_union_tag)
1537
1532
{
1538
1533
error ().source_location = expr.source_location ();
1539
1534
error () << " member operator requires structure type "
@@ -1542,8 +1537,8 @@ void c_typecheck_baset::typecheck_expr_member(exprt &expr)
1542
1537
throw 0 ;
1543
1538
}
1544
1539
1545
- const struct_union_typet &struct_union_type=
1546
- to_struct_union_type ( type);
1540
+ const struct_union_typet &struct_union_type =
1541
+ follow_struct_or_union_tag ( to_struct_or_union_tag_type ( type) );
1547
1542
1548
1543
if (struct_union_type.is_incomplete ())
1549
1544
{
@@ -1585,8 +1580,12 @@ void c_typecheck_baset::typecheck_expr_member(exprt &expr)
1585
1580
if (op0.get_bool (ID_C_lvalue))
1586
1581
expr.set (ID_C_lvalue, true );
1587
1582
1588
- if (op0.type ().get_bool (ID_C_constant) || type.get_bool (ID_C_constant))
1583
+ if (
1584
+ op0.type ().get_bool (ID_C_constant) ||
1585
+ struct_union_type.get_bool (ID_C_constant))
1586
+ {
1589
1587
expr.type ().set (ID_C_constant, true );
1588
+ }
1590
1589
1591
1590
// copy method identifier
1592
1591
const irep_idt &identifier=component.get (ID_C_identifier);
@@ -3649,11 +3648,10 @@ exprt c_typecheck_baset::do_special_functions(
3649
3648
3650
3649
// The value doesn't matter at all, we only care about the type.
3651
3650
// Need to sync with typeclass.h.
3652
- typet type = follow (object.type ());
3653
-
3654
3651
// use underlying type for bit fields
3655
- if (type.id () == ID_c_bit_field)
3656
- type = to_c_bit_field_type (type).underlying_type ();
3652
+ const typet &type = object.type ().id () == ID_c_bit_field
3653
+ ? to_c_bit_field_type (object.type ()).underlying_type ()
3654
+ : object.type ();
3657
3655
3658
3656
unsigned type_number;
3659
3657
@@ -3665,23 +3663,17 @@ exprt c_typecheck_baset::do_special_functions(
3665
3663
}
3666
3664
else
3667
3665
{
3668
- type_number =
3669
- type.id () == ID_empty
3670
- ? 0u
3671
- : (type.id () == ID_bool || type.id () == ID_c_bool)
3672
- ? 4u
3673
- : (type.id () == ID_pointer || type.id () == ID_array)
3674
- ? 5u
3675
- : type.id () == ID_floatbv
3676
- ? 8u
3677
- : (type.id () == ID_complex &&
3678
- to_complex_type (type).subtype ().id () == ID_floatbv)
3679
- ? 9u
3680
- : type.id () == ID_struct
3681
- ? 12u
3682
- : type.id () == ID_union
3683
- ? 13u
3684
- : 1u ; // int, short, char, enum_tag
3666
+ type_number = type.id () == ID_empty ? 0u
3667
+ : (type.id () == ID_bool || type.id () == ID_c_bool) ? 4u
3668
+ : (type.id () == ID_pointer || type.id () == ID_array) ? 5u
3669
+ : type.id () == ID_floatbv ? 8u
3670
+ : (type.id () == ID_complex &&
3671
+ to_complex_type (type).subtype ().id () == ID_floatbv)
3672
+ ? 9u
3673
+ : type.id () == ID_struct_tag ? 12u
3674
+ : type.id () == ID_union_tag
3675
+ ? 13u
3676
+ : 1u ; // int, short, char, enum_tag
3685
3677
}
3686
3678
3687
3679
exprt tmp=from_integer (type_number, expr.type ());
0 commit comments