@@ -687,7 +687,8 @@ bool cpp_typecheckt::standard_conversion_sequence(
687687
688688 // bit fields are converted like their underlying type
689689 if (type.id ()==ID_c_bit_field)
690- return standard_conversion_sequence (expr, type.subtype (), new_expr, rank);
690+ return standard_conversion_sequence (
691+ expr, to_c_bit_field_type (type).underlying_type (), new_expr, rank);
691692
692693 // we turn bit fields into their underlying type
693694 if (curr_expr.type ().id ()==ID_c_bit_field)
@@ -774,7 +775,9 @@ bool cpp_typecheckt::standard_conversion_sequence(
774775 }
775776 else if (type.id ()==ID_pointer)
776777 {
777- if (expr.type ().subtype ().id ()==ID_nullptr)
778+ if (
779+ expr.type ().id () == ID_pointer &&
780+ to_pointer_type (expr.type ()).base_type ().id () == ID_nullptr)
778781 {
779782 // std::nullptr_t to _any_ pointer type is ok
780783 new_expr = typecast_exprt::conditional_cast (new_expr, type);
@@ -1132,9 +1135,9 @@ bool cpp_typecheckt::reference_related(
11321135 return subtype_typecast (to_struct_type (from),
11331136 to_struct_type (to));
11341137
1135- if (from. id ()==ID_struct &&
1136- type.get_bool (ID_C_this) &&
1137- type. subtype ().id ()== ID_empty)
1138+ if (
1139+ from. id () == ID_struct && type.get_bool (ID_C_this) &&
1140+ to_pointer_type ( type). base_type ().id () == ID_empty)
11381141 {
11391142 // virtual-call case
11401143 return true ;
@@ -1158,14 +1161,14 @@ bool cpp_typecheckt::reference_compatible(
11581161 if (!reference_related (expr, type))
11591162 return false ;
11601163
1161- if (expr.type ()!= type. subtype ())
1164+ if (expr.type () != to_reference_type ( type). base_type ())
11621165 rank+=3 ;
11631166
11641167 c_qualifierst qual_from;
11651168 qual_from.read (expr.type ());
11661169
11671170 c_qualifierst qual_to;
1168- qual_to.read (type. subtype ());
1171+ qual_to.read (to_reference_type ( type). base_type ());
11691172
11701173 if (qual_from!=qual_to)
11711174 rank+=1 ;
@@ -1264,7 +1267,7 @@ bool cpp_typecheckt::reference_binding(
12641267 new_expr.swap (tmp);
12651268 }
12661269
1267- if (expr.type ()!= type. subtype ())
1270+ if (expr.type () != to_reference_type ( type). base_type ())
12681271 {
12691272 c_qualifierst qual_from;
12701273 qual_from.read (expr.type ());
@@ -1341,7 +1344,7 @@ bool cpp_typecheckt::reference_binding(
13411344
13421345 new_expr = to_multi_ary_expr (returned_value).op0 ();
13431346
1344- if (returned_value.type () != type. subtype ())
1347+ if (returned_value.type () != to_reference_type ( type). base_type ())
13451348 {
13461349 c_qualifierst qual_from;
13471350 qual_from.read (returned_value.type ());
@@ -1359,13 +1362,15 @@ bool cpp_typecheckt::reference_binding(
13591362 if (type.get_bool (ID_C_this))
13601363 return false ;
13611364
1362- if (!type.subtype ().get_bool (ID_C_constant) ||
1363- type.subtype ().get_bool (ID_C_volatile))
1365+ if (
1366+ !to_reference_type (type).base_type ().get_bool (ID_C_constant) ||
1367+ to_reference_type (type).base_type ().get_bool (ID_C_volatile))
13641368 return false ;
13651369
13661370 // TODO: handle the case for implicit parameters
1367- if (!type.subtype ().get_bool (ID_C_constant) &&
1368- !expr.get_bool (ID_C_lvalue))
1371+ if (
1372+ !to_reference_type (type).base_type ().get_bool (ID_C_constant) &&
1373+ !expr.get_bool (ID_C_lvalue))
13691374 return false ;
13701375
13711376 exprt arg_expr=expr;
@@ -1376,7 +1381,8 @@ bool cpp_typecheckt::reference_binding(
13761381 arg_expr.set (ID_C_lvalue, true );
13771382 }
13781383
1379- if (user_defined_conversion_sequence (arg_expr, type.subtype (), new_expr, rank))
1384+ if (user_defined_conversion_sequence (
1385+ arg_expr, to_reference_type (type).base_type (), new_expr, rank))
13801386 {
13811387 address_of_exprt tmp (new_expr, reference_type (new_expr.type ()));
13821388 tmp.add_source_location ()=new_expr.source_location ();
@@ -1385,12 +1391,15 @@ bool cpp_typecheckt::reference_binding(
13851391 }
13861392
13871393 rank=backup_rank;
1388- if (standard_conversion_sequence (expr, type.subtype (), new_expr, rank))
1394+ if (standard_conversion_sequence (
1395+ expr, to_reference_type (type).base_type (), new_expr, rank))
13891396 {
13901397 {
13911398 // create temporary object
13921399 side_effect_exprt tmp (
1393- ID_temporary_object, type.subtype (), expr.source_location ());
1400+ ID_temporary_object,
1401+ to_reference_type (type).base_type (),
1402+ expr.source_location ());
13941403 tmp.set (ID_mode, ID_cpp);
13951404 // tmp.set(ID_C_lvalue, true);
13961405 tmp.add_to_operands (std::move (new_expr));
0 commit comments