@@ -356,8 +356,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
356
356
throw 0 ;
357
357
}
358
358
359
- if (is_constructor &&
360
- base_name!=id2string (symbol.base_name ))
359
+ if (is_constructor && base_name != symbol.base_name )
361
360
{
362
361
error ().source_location =cpp_name.source_location ();
363
362
error () << " member function must return a value or void" << eom;
@@ -425,7 +424,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
425
424
}
426
425
427
426
if (is_typedef)
428
- component.set (" is_type " , true );
427
+ component.set (ID_is_type , true );
429
428
430
429
if (is_mutable)
431
430
component.set (" is_mutable" , true );
@@ -448,7 +447,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
448
447
virtual_name+=" $const" ;
449
448
450
449
if (has_volatile (method_qualifier))
451
- virtual_name+= " $virtual " ;
450
+ virtual_name += " $volatile " ;
452
451
453
452
if (component.type ().get (ID_return_type)==ID_destructor)
454
453
virtual_name=" @dtor" ;
@@ -491,22 +490,18 @@ void cpp_typecheckt::typecheck_compound_declarator(
491
490
component.type ().set (" #virtual_name" , virtual_name);
492
491
493
492
// Check if it is a pure virtual method
494
- if (is_virtual )
493
+ if (value. is_not_nil () && value. id () == ID_constant )
495
494
{
496
- if (value.is_not_nil () && value.id ()==ID_constant)
495
+ mp_integer i;
496
+ to_integer (value, i);
497
+ if (i!=0 )
497
498
{
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 ;
509
502
}
503
+ component.set (" is_pure_virtual" , true );
504
+ value.make_nil ();
510
505
}
511
506
512
507
typecheck_member_function (
@@ -615,47 +610,36 @@ void cpp_typecheckt::typecheck_compound_declarator(
615
610
616
611
// do the body of the function
617
612
typecast_exprt late_cast (
613
+ lookup (args[0 ].get (ID_C_identifier)).symbol_expr (),
618
614
to_code_type (component.type ()).parameters ()[0 ].type ());
619
615
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
+ }
623
627
624
628
if (code_type.return_type ().id ()!=ID_empty &&
625
629
code_type.return_type ().id ()!=ID_destructor)
626
630
{
627
- side_effect_expr_function_callt expr_call;
628
- expr_call.function ()=
629
- symbol_exprt (component.get_name (), component.type ());
630
631
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 );
633
634
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 ();
642
636
}
643
637
else
644
638
{
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);
650
641
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 ();
659
643
}
660
644
661
645
// add this new function to the list of components
@@ -671,6 +655,8 @@ void cpp_typecheckt::typecheck_compound_declarator(
671
655
CHECK_RETURN (!failed);
672
656
}
673
657
658
+ put_compound_into_scope (new_compo);
659
+
674
660
// next base
675
661
virtual_bases.erase (virtual_bases.begin ());
676
662
}
0 commit comments