diff --git a/regression/goto-analyzer/reachable-functions-basic-json/test.desc b/regression/goto-analyzer/reachable-functions-basic-json/test.desc index 56938b7514e..c7c9455ee76 100644 --- a/regression/goto-analyzer/reachable-functions-basic-json/test.desc +++ b/regression/goto-analyzer/reachable-functions-basic-json/test.desc @@ -6,4 +6,5 @@ CORE "function": "obviously_dead",$ "function": "not_obviously_dead",$ -- +"last line":[[:space:]]*$ ^warning: ignoring diff --git a/regression/goto-analyzer/unreachable-functions-basic-json/test.desc b/regression/goto-analyzer/unreachable-functions-basic-json/test.desc index 1a343aab6f1..8828b4bbb17 100644 --- a/regression/goto-analyzer/unreachable-functions-basic-json/test.desc +++ b/regression/goto-analyzer/unreachable-functions-basic-json/test.desc @@ -6,4 +6,5 @@ CORE "function": "not_called", "last line": 6 -- +"last line":[[:space:]]*$ ^warning: ignoring diff --git a/src/goto-analyzer/unreachable_instructions.cpp b/src/goto-analyzer/unreachable_instructions.cpp index 81fe0c608ec..0e783baaba5 100644 --- a/src/goto-analyzer/unreachable_instructions.cpp +++ b/src/goto-analyzer/unreachable_instructions.cpp @@ -325,9 +325,21 @@ static void list_functions( goto_programt::const_targett end_function= goto_program.instructions.end(); - --end_function; - assert(end_function->is_end_function()); - last_location=end_function->source_location; + + // find the last instruction with a line number + // TODO(tautschnig): #918 will eventually ensure that every instruction + // has such + do + { + --end_function; + last_location = end_function->source_location; + } + while( + end_function != goto_program.instructions.begin() && + last_location.get_line().empty()); + + if(last_location.get_line().empty()) + last_location = decl.location; } else // completely ignore functions without a body, both for