@@ -127,6 +127,13 @@ void cpp_typecheckt::typecheck_expr_main(exprt &expr)
127127 {
128128 expr.type ().id (ID_initializer_list);
129129 }
130+ else if (expr.id () == ID_const_cast ||
131+ expr.id () == ID_dynamic_cast ||
132+ expr.id () == ID_reinterpret_cast ||
133+ expr.id () == ID_static_cast)
134+ {
135+ typecheck_cast_expr (expr);
136+ }
130137 else
131138 c_typecheck_baset::typecheck_expr_main (expr);
132139}
@@ -967,13 +974,8 @@ void cpp_typecheckt::typecheck_expr_explicit_constructor_call(exprt &expr)
967974 }
968975 else
969976 {
970- CHECK_RETURN (expr.type ().id () == ID_struct);
971-
972- struct_tag_typet tag (expr.type ().get (ID_name));
973- tag.add_source_location () = expr.source_location ();
974-
975977 exprt e=expr;
976- new_temporary (e.source_location (), tag , e.operands (), expr);
978+ new_temporary (e.source_location (), e. type () , e.operands (), expr);
977979 }
978980}
979981
@@ -1275,53 +1277,20 @@ void cpp_typecheckt::typecheck_expr_ptrmember(
12751277
12761278void cpp_typecheckt::typecheck_cast_expr (exprt &expr)
12771279{
1278- side_effect_expr_function_callt e =
1279- to_side_effect_expr_function_call (expr);
1280-
1281- if (e.arguments ().size () != 1 )
1280+ if (expr.operands ().size () != 1 )
12821281 {
12831282 error ().source_location =expr.find_source_location ();
12841283 error () << " cast expressions expect one operand" << eom;
12851284 throw 0 ;
12861285 }
12871286
1288- exprt &f_op=e.function ();
1289- exprt &cast_op=e.arguments ().front ();
1287+ exprt &cast_op = to_unary_expr (expr).op ();
12901288
12911289 add_implicit_dereference (cast_op);
12921290
1293- const irep_idt &id=
1294- f_op.get_sub ().front ().get (ID_identifier);
1295-
1296- if (f_op.get_sub ().size ()!=2 ||
1297- f_op.get_sub ()[1 ].id ()!=ID_template_args)
1298- {
1299- error ().source_location =expr.find_source_location ();
1300- error () << id << " expects template argument" << eom;
1301- throw 0 ;
1302- }
1303-
1304- irept &template_arguments=f_op.get_sub ()[1 ].add (ID_arguments);
1305-
1306- if (template_arguments.get_sub ().size ()!=1 )
1307- {
1308- error ().source_location =expr.find_source_location ();
1309- error () << id << " expects one template argument" << eom;
1310- throw 0 ;
1311- }
1312-
1313- irept &template_arg=template_arguments.get_sub ().front ();
1314-
1315- if (template_arg.id () != ID_type && template_arg.id () != ID_ambiguous)
1316- {
1317- error ().source_location =expr.find_source_location ();
1318- error () << id << " expects a type as template argument" << eom;
1319- throw 0 ;
1320- }
1321-
1322- typet &type=static_cast <typet &>(
1323- template_arguments.get_sub ().front ().add (ID_type));
1291+ const irep_idt &id = expr.id ();
13241292
1293+ typet &type = expr.type ();
13251294 typecheck_type (type);
13261295
13271296 source_locationt source_location=expr.source_location ();
@@ -1415,21 +1384,6 @@ void cpp_typecheckt::typecheck_expr_cpp_name(
14151384 }
14161385 }
14171386
1418- if (expr.get_sub ().size ()>=1 &&
1419- expr.get_sub ().front ().id ()==ID_name)
1420- {
1421- const irep_idt &id=expr.get_sub ().front ().get (ID_identifier);
1422-
1423- if (id==ID_const_cast ||
1424- id==ID_dynamic_cast ||
1425- id==ID_reinterpret_cast ||
1426- id==ID_static_cast)
1427- {
1428- expr.id (ID_cast_expression);
1429- return ;
1430- }
1431- }
1432-
14331387 exprt symbol_expr=
14341388 resolve (
14351389 to_cpp_name (expr),
@@ -1556,14 +1510,6 @@ void cpp_typecheckt::typecheck_side_effect_function_call(
15561510
15571511 return ;
15581512 }
1559- else if (expr.function ().id () == ID_cast_expression)
1560- {
1561- // These are not really function calls,
1562- // but usually just type adjustments.
1563- typecheck_cast_expr (expr);
1564- add_implicit_dereference (expr);
1565- return ;
1566- }
15671513 else if (expr.function ().id () == ID_cpp_dummy_destructor)
15681514 {
15691515 // these don't do anything, e.g., (char*)->~char()
0 commit comments