From b7f2cfbf0fc7bcd5c1e60fca354de8bf60f9acfa Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 22 Oct 2020 06:12:31 -0400 Subject: [PATCH] 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. --- gcc/analyzer/engine.cc | 5 +++++ gcc/testsuite/g++.dg/analyzer/pr97489.C | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 gcc/testsuite/g++.dg/analyzer/pr97489.C diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc index 65d7495f26f..b1c877e5231 100644 --- a/gcc/analyzer/engine.cc +++ b/gcc/analyzer/engine.cc @@ -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) { diff --git a/gcc/testsuite/g++.dg/analyzer/pr97489.C b/gcc/testsuite/g++.dg/analyzer/pr97489.C new file mode 100644 index 00000000000..9322e72f5c4 --- /dev/null +++ b/gcc/testsuite/g++.dg/analyzer/pr97489.C @@ -0,0 +1,6 @@ +struct X { + virtual ~X() {} + virtual void key_function(); +}; + +void X::key_function() {} -- 2.30.2