@@ -616,22 +616,24 @@ void goto_convertt::convert_frontend_decl(
616
616
symbol.type .id ()==ID_code)
617
617
return ; // this is a SKIP!
618
618
619
- if (code.operands ().size ()==1 )
620
- {
621
- copy (code, DECL, dest);
622
- }
623
- else
624
- {
619
+ const goto_programt::targett declaration_iterator = [&]() {
620
+ if (code.operands ().size () == 1 )
621
+ {
622
+ copy (code, DECL, dest);
623
+ return std::prev (dest.instructions .end ());
624
+ }
625
+
625
626
exprt initializer = code.op1 ();
626
627
627
- codet tmp= code;
628
+ codet tmp = code;
628
629
tmp.operands ().resize (1 );
629
630
// hide this declaration-without-initializer step in the goto trace
630
631
tmp.add_source_location ().set_hide ();
631
632
632
633
// Break up into decl and assignment.
633
634
// Decl must be visible before initializer.
634
635
copy (tmp, DECL, dest);
636
+ const auto declaration_iterator = std::prev (dest.instructions .end ());
635
637
636
638
auto initializer_location = initializer.find_source_location ();
637
639
clean_expr (initializer, dest, mode);
@@ -643,7 +645,9 @@ void goto_convertt::convert_frontend_decl(
643
645
644
646
convert_assign (assign, dest, mode);
645
647
}
646
- }
648
+
649
+ return declaration_iterator;
650
+ }();
647
651
648
652
// now create a 'dead' instruction -- will be added after the
649
653
// destructor created below as unwind_destructor_stack pops off the
@@ -652,7 +656,8 @@ void goto_convertt::convert_frontend_decl(
652
656
653
657
{
654
658
code_deadt code_dead (symbol_expr);
655
- targets.scope_stack .add (code_dead, {});
659
+
660
+ targets.scope_stack .add (code_dead, {declaration_iterator});
656
661
}
657
662
658
663
// do destructor
0 commit comments