@@ -356,8 +356,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
356356 throw 0 ;
357357 }
358358
359- if (is_constructor &&
360- base_name!=id2string (symbol.base_name ))
359+ if (is_constructor && base_name != symbol.base_name )
361360 {
362361 error ().source_location =cpp_name.source_location ();
363362 error () << " member function must return a value or void" << eom;
@@ -425,7 +424,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
425424 }
426425
427426 if (is_typedef)
428- component.set (" is_type " , true );
427+ component.set (ID_is_type , true );
429428
430429 if (is_mutable)
431430 component.set (" is_mutable" , true );
@@ -448,7 +447,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
448447 virtual_name+=" $const" ;
449448
450449 if (has_volatile (method_qualifier))
451- virtual_name+= " $virtual " ;
450+ virtual_name += " $volatile " ;
452451
453452 if (component.type ().get (ID_return_type)==ID_destructor)
454453 virtual_name=" @dtor" ;
@@ -491,22 +490,18 @@ void cpp_typecheckt::typecheck_compound_declarator(
491490 component.type ().set (" #virtual_name" , virtual_name);
492491
493492 // Check if it is a pure virtual method
494- if (is_virtual )
493+ if (value. is_not_nil () && value. id () == ID_constant )
495494 {
496- if (value.is_not_nil () && value.id ()==ID_constant)
495+ mp_integer i;
496+ to_integer (value, i);
497+ if (i!=0 )
497498 {
498- mp_integer i;
499- to_integer (value, i);
500- if (i!=0 )
501- {
502- error ().source_location =declarator.name ().source_location ();
503- error () << " expected 0 to mark pure virtual method, got "
504- << i << eom;
505- throw 0 ;
506- }
507- component.set (" is_pure_virtual" , true );
508- value.make_nil ();
499+ error ().source_location = declarator.name ().source_location ();
500+ error () << " expected 0 to mark pure virtual method, got " << i << eom;
501+ throw 0 ;
509502 }
503+ component.set (" is_pure_virtual" , true );
504+ value.make_nil ();
510505 }
511506
512507 typecheck_member_function (
@@ -615,47 +610,36 @@ void cpp_typecheckt::typecheck_compound_declarator(
615610
616611 // do the body of the function
617612 typecast_exprt late_cast (
613+ lookup (args[0 ].get (ID_C_identifier)).symbol_expr (),
618614 to_code_type (component.type ()).parameters ()[0 ].type ());
619615
620- late_cast.op0 ()=
621- namespacet (symbol_table).lookup (
622- args[0 ].get (ID_C_identifier)).symbol_expr ();
616+ side_effect_expr_function_callt expr_call;
617+ expr_call.function () =
618+ symbol_exprt (component.get_name (), component.type ());
619+ expr_call.arguments ().reserve (args.size ());
620+ expr_call.arguments ().push_back (late_cast);
621+
622+ for (const auto &arg : args)
623+ {
624+ expr_call.arguments ().push_back (
625+ lookup (arg.get (ID_C_identifier)).symbol_expr ());
626+ }
623627
624628 if (code_type.return_type ().id ()!=ID_empty &&
625629 code_type.return_type ().id ()!=ID_destructor)
626630 {
627- side_effect_expr_function_callt expr_call;
628- expr_call.function ()=
629- symbol_exprt (component.get_name (), component.type ());
630631 expr_call.type ()=to_code_type (component.type ()).return_type ();
631- expr_call. arguments (). reserve (args. size () );
632- expr_call. arguments (). push_back (late_cast );
632+ exprt already_typechecked (ID_already_typechecked );
633+ already_typechecked. move_to_operands (expr_call );
633634
634- for (std::size_t i=1 ; i < args.size (); i++)
635- {
636- expr_call.arguments ().push_back (
637- namespacet (symbol_table).lookup (
638- args[i].get (ID_C_identifier)).symbol_expr ());
639- }
640-
641- func_symb.value =code_returnt (expr_call);
635+ func_symb.value = code_returnt (already_typechecked).make_block ();
642636 }
643637 else
644638 {
645- code_function_callt code_func;
646- code_func.function ()=
647- symbol_exprt (component.get_name (), component.type ());
648- code_func.arguments ().reserve (args.size ());
649- code_func.arguments ().push_back (late_cast);
639+ exprt already_typechecked (ID_already_typechecked);
640+ already_typechecked.move_to_operands (expr_call);
650641
651- for (std::size_t i=1 ; i < args.size (); i++)
652- {
653- code_func.arguments ().push_back (
654- namespacet (symbol_table).lookup (
655- args[i].get (ID_C_identifier)).symbol_expr ());
656- }
657-
658- func_symb.value =code_func;
642+ func_symb.value = code_expressiont (already_typechecked).make_block ();
659643 }
660644
661645 // add this new function to the list of components
@@ -671,6 +655,8 @@ void cpp_typecheckt::typecheck_compound_declarator(
671655 CHECK_RETURN (!failed);
672656 }
673657
658+ put_compound_into_scope (new_compo);
659+
674660 // next base
675661 virtual_bases.erase (virtual_bases.begin ());
676662 }
0 commit comments