Skip to content

Commit 252af48

Browse files
committed
add missing source_location for assignments generated for initializers
A variable definition in C may include an initializer. We split these into a DECL instruction and an ASSIGN instruction. This commit ensures that the ASSIGN instruction has a source_location attached to it (clean_expr may yield a temporary, which does not appear in the source code).
1 parent a702e77 commit 252af48

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/goto-programs/goto_convert.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,12 +637,13 @@ void goto_convertt::convert_frontend_decl(
637637
// Decl must be visible before initializer.
638638
copy(tmp, DECL, dest);
639639

640+
auto initializer_location = initializer.find_source_location();
640641
clean_expr(initializer, dest, mode);
641642

642643
if(initializer.is_not_nil())
643644
{
644645
code_assignt assign(code.op0(), initializer);
645-
assign.add_source_location() = initializer.find_source_location();
646+
assign.add_source_location() = initializer_location;
646647

647648
convert_assign(assign, dest, mode);
648649
}

0 commit comments

Comments
 (0)