analyzer: fix ICE on dtor [PR97489]

gcc/analyzer/ChangeLog:
	PR analyzer/97489
	* engine.cc (exploded_graph::add_function_entry): Assert that we
	have a function body.
	(exploded_graph::on_escaped_function): Reject fndecls that don't
	have a function body.

gcc/testsuite/ChangeLog:
	PR analyzer/97489
	* g++.dg/analyzer/pr97489.C: New test.
This commit is contained in:
David Malcolm 2020-10-22 06:12:31 -04:00
parent 56ddd5e23a
commit b7f2cfbf0f
2 changed files with 11 additions and 0 deletions

View File

@ -1937,6 +1937,8 @@ exploded_graph::~exploded_graph ()
exploded_node *
exploded_graph::add_function_entry (function *fun)
{
gcc_assert (gimple_has_body_p (fun->decl));
/* Be idempotent. */
if (m_functions_with_enodes.contains (fun))
{
@ -3982,6 +3984,9 @@ exploded_graph::on_escaped_function (tree fndecl)
if (!fun)
return;
if (!gimple_has_body_p (fndecl))
return;
exploded_node *enode = add_function_entry (fun);
if (logger)
{

View File

@ -0,0 +1,6 @@
struct X {
virtual ~X() {}
virtual void key_function();
};
void X::key_function() {}