@@ -250,9 +250,11 @@ void cpp_typecheckt::typecheck_expr_trinary(if_exprt &expr)
250250 expr.type ()=e2 .type ();
251251 expr.op2 ().swap (e2 );
252252 }
253- else if (expr.op1 ().type ().id ()==ID_array &&
254- expr.op2 ().type ().id ()==ID_array &&
255- expr.op1 ().type ().subtype () == expr.op2 ().type ().subtype ())
253+ else if (
254+ expr.op1 ().type ().id () == ID_array &&
255+ expr.op2 ().type ().id () == ID_array &&
256+ to_array_type (expr.op1 ().type ()).element_type () ==
257+ to_array_type (expr.op2 ().type ()).element_type ())
256258 {
257259 // array-to-pointer conversion
258260
@@ -409,7 +411,7 @@ bool cpp_typecheckt::overloadable(const exprt &expr)
409411 typet t = it->type ();
410412
411413 if (is_reference (t))
412- t=t. subtype ();
414+ t = to_reference_type (t). base_type ();
413415
414416 if (
415417 t.id () == ID_struct || t.id () == ID_union || t.id () == ID_c_enum ||
@@ -693,7 +695,8 @@ void cpp_typecheckt::typecheck_expr_address_of(exprt &expr)
693695 if (op.id () == ID_address_of && op.get_bool (ID_C_implicit))
694696 {
695697 // must be the address of a function
696- code_typet &code_type=to_code_type (op.type ().subtype ());
698+ code_typet &code_type =
699+ to_code_type (to_pointer_type (op.type ()).base_type ());
697700
698701 code_typet::parameterst &args=code_type.parameters ();
699702 if (!args.empty () && args.front ().get_this ())
@@ -714,15 +717,16 @@ void cpp_typecheckt::typecheck_expr_address_of(exprt &expr)
714717 else if (op.id () == ID_ptrmember && to_unary_expr (op).op ().id () == " cpp-this" )
715718 {
716719 expr.type () = pointer_type (op.type ());
717- expr.type ().add (ID_to_member) = to_unary_expr (op).op ().type ().subtype ();
720+ expr.type ().add (ID_to_member) =
721+ to_pointer_type (to_unary_expr (op).op ().type ()).base_type ();
718722 return ;
719723 }
720724
721725 // the C front end does not know about references
722726 const bool is_ref=is_reference (expr.type ());
723727 c_typecheck_baset::typecheck_expr_address_of (expr);
724728 if (is_ref)
725- expr.type ()= reference_type (expr.type (). subtype ());
729+ expr.type () = reference_type (to_pointer_type ( expr.type ()). base_type ());
726730}
727731
728732void cpp_typecheckt::typecheck_expr_throw (exprt &expr)
@@ -756,8 +760,8 @@ void cpp_typecheckt::typecheck_expr_new(exprt &expr)
756760
757761 if (expr.type ().id ()==ID_array)
758762 {
759- // first typecheck subtype
760- typecheck_type (expr.type (). subtype ());
763+ // first typecheck the element type
764+ typecheck_type (to_array_type ( expr.type ()). element_type ());
761765
762766 // typecheck the size
763767 exprt &size=to_array_type (expr.type ()).size ();
@@ -774,8 +778,8 @@ void cpp_typecheckt::typecheck_expr_new(exprt &expr)
774778 expr.set (ID_size, to_array_type (expr.type ()).size ());
775779
776780 // new actually returns a pointer, not an array
777- pointer_typet ptr_type=
778- pointer_type (expr.type (). subtype ());
781+ pointer_typet ptr_type =
782+ pointer_type (to_array_type ( expr.type ()). element_type ());
779783 expr.type ().swap (ptr_type);
780784 }
781785 else
@@ -789,7 +793,7 @@ void cpp_typecheckt::typecheck_expr_new(exprt &expr)
789793 expr.type ().swap (ptr_type);
790794 }
791795
792- exprt object_expr (ID_new_object, expr.type (). subtype ());
796+ exprt object_expr (ID_new_object, to_pointer_type ( expr.type ()). base_type ());
793797 object_expr.set (ID_C_lvalue, true );
794798
795799 already_typechecked_exprt::make_already_typechecked (object_expr);
@@ -817,13 +821,15 @@ void cpp_typecheckt::typecheck_expr_new(exprt &expr)
817821
818822 // we add the size of the object for convenience of the
819823 // runtime library
820- auto size_of_opt = size_of_expr (expr.type ().subtype (), *this );
824+ auto size_of_opt =
825+ size_of_expr (to_pointer_type (expr.type ()).base_type (), *this );
821826
822827 if (size_of_opt.has_value ())
823828 {
824829 auto &sizeof_expr = static_cast <exprt &>(expr.add (ID_sizeof));
825830 sizeof_expr = size_of_opt.value ();
826- sizeof_expr.add (ID_C_c_sizeof_type) = expr.type ().subtype ();
831+ sizeof_expr.add (ID_C_c_sizeof_type) =
832+ to_pointer_type (expr.type ()).base_type ();
827833 }
828834}
829835
@@ -1024,14 +1030,14 @@ void cpp_typecheckt::typecheck_expr_delete(exprt &expr)
10241030
10251031 // remove any const-ness of the argument
10261032 // (which would impair the call to the destructor)
1027- pointer_type. subtype ().remove (ID_C_constant);
1033+ to_pointer_type ( pointer_type). base_type ().remove (ID_C_constant);
10281034
10291035 // delete expressions are always void
10301036 expr.type ()=typet (ID_empty);
10311037
10321038 // we provide the right destructor, for the convenience
10331039 // of later stages
1034- exprt new_object (ID_new_object, pointer_type. subtype ());
1040+ exprt new_object (ID_new_object, to_pointer_type ( pointer_type). base_type ());
10351041 new_object.add_source_location ()=expr.source_location ();
10361042 new_object.set (ID_C_lvalue, true );
10371043
@@ -1636,13 +1642,13 @@ void cpp_typecheckt::typecheck_side_effect_function_call(
16361642 }
16371643
16381644 // get the virtual table
1639- typet this_type=
1640- to_code_type (expr.function ().type ()).parameters ().front ().type ();
1641- irep_idt vtable_name=
1642- this_type.subtype ().get_string (ID_identifier) +" ::@vtable_pointer" ;
1645+ auto this_type = to_pointer_type (
1646+ to_code_type (expr.function ().type ()).parameters ().front ().type ()) ;
1647+ irep_idt vtable_name =
1648+ this_type.base_type ().get_string (ID_identifier) + " ::@vtable_pointer" ;
16431649
1644- const struct_typet &vt_struct=
1645- to_struct_type (follow (this_type.subtype ()));
1650+ const struct_typet &vt_struct =
1651+ to_struct_type (follow (this_type.base_type ()));
16461652
16471653 const struct_typet::componentt &vt_compo=
16481654 vt_struct.get_component (vtable_name);
@@ -2011,7 +2017,7 @@ void cpp_typecheckt::typecheck_side_effect_assignment(side_effect_exprt &expr)
20112017 typet type0 = to_binary_expr (expr).op0 ().type ();
20122018
20132019 if (is_reference (type0))
2014- type0= type0. subtype ();
2020+ type0 = to_reference_type ( type0). base_type ();
20152021
20162022 if (cpp_is_pod (type0))
20172023 {
@@ -2188,7 +2194,9 @@ void cpp_typecheckt::convert_pmop(exprt &expr)
21882194 throw 0 ;
21892195 }
21902196
2191- typet t0 = op0.type ().id () == ID_pointer ? op0.type ().subtype () : op0.type ();
2197+ typet t0 = op0.type ().id () == ID_pointer
2198+ ? to_pointer_type (op0.type ()).base_type ()
2199+ : op0.type ();
21922200
21932201 typet t1 ((const typet &)op1.type ().find (ID_to_member));
21942202
0 commit comments