Skip to content

Commit 1199c56

Browse files
authored
Merge pull request #7322 from tautschnig/cleanup/get_target-typing
goto_programt::get_target: fix const-ness of operations
2 parents 0060417 + 943333a commit 1199c56

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/goto-programs/goto_convert.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ void goto_convertt::optimize_guarded_gotos(goto_programt &dest)
243243

244244
// mark the goto targets
245245
unsigned cnt = 0;
246-
for(const auto &i : dest.instructions)
246+
for(auto &i : dest.instructions)
247247
if(i.is_goto())
248248
i.get_target()->target_number = (++cnt);
249249

src/goto-programs/goto_program.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,15 @@ class goto_programt
395395

396396
/// Returns the first (and only) successor for the usual case of a single
397397
/// target
398-
targett get_target() const
398+
const_targett get_target() const
399+
{
400+
PRECONDITION(targets.size() == 1);
401+
return targets.front();
402+
}
403+
404+
/// Returns the first (and only) successor for the usual case of a single
405+
/// target
406+
targett get_target()
399407
{
400408
PRECONDITION(targets.size()==1);
401409
return targets.front();

0 commit comments

Comments
 (0)