Commit d8cde6f9 by David Malcolm

analyzer: fix ICE on function pointer casts [PR 93775]

PR analyzer/93775 reports an ICE in cgraph_node::get when -fanalyzer is
used on code that calls a function pointer that was generated via a cast
from a non-function.

This patch fixes it by bulletproofing region_model::get_fndecl_for_call
for the case where the code_region's get_tree_for_child_region returns
NULL.

gcc/analyzer/ChangeLog:
	PR analyzer/93775
	* region-model.cc (region_model::get_fndecl_for_call): Handle the
	case where the code_region's get_tree_for_child_region returns
	NULL.

gcc/testsuite/ChangeLog:
	PR analyzer/93775
	* gcc.dg/analyzer/20020129-1.c: New test.
parent 1ee98e41
2020-02-17 David Malcolm <dmalcolm@redhat.com> 2020-02-17 David Malcolm <dmalcolm@redhat.com>
PR analyzer/93775
* region-model.cc (region_model::get_fndecl_for_call): Handle the
case where the code_region's get_tree_for_child_region returns
NULL.
2020-02-17 David Malcolm <dmalcolm@redhat.com>
PR analyzer/93388 PR analyzer/93388
* engine.cc (impl_region_model_context::on_unknown_tree_code): * engine.cc (impl_region_model_context::on_unknown_tree_code):
New. New.
......
...@@ -6693,6 +6693,8 @@ region_model::get_fndecl_for_call (const gcall *call, ...@@ -6693,6 +6693,8 @@ region_model::get_fndecl_for_call (const gcall *call,
if (code) if (code)
{ {
tree fn_decl = code->get_tree_for_child_region (fn_rid); tree fn_decl = code->get_tree_for_child_region (fn_rid);
if (!fn_decl)
return NULL_TREE;
const cgraph_node *ultimate_node const cgraph_node *ultimate_node
= cgraph_node::get (fn_decl)->ultimate_alias_target (); = cgraph_node::get (fn_decl)->ultimate_alias_target ();
if (ultimate_node) if (ultimate_node)
......
2020-02-17 David Malcolm <dmalcolm@redhat.com>
PR analyzer/93775
* gcc.dg/analyzer/20020129-1.c: New test.
2020-02-17 Alexandre Oliva <oliva@adacore.com> 2020-02-17 Alexandre Oliva <oliva@adacore.com>
* gcc.dg/tls/emutls-3.c: New, combining emutls-2.c and * gcc.dg/tls/emutls-3.c: New, combining emutls-2.c and
......
/* { dg-require-effective-target indirect_calls } */
#include "../../gcc.c-torture/compile/20020129-1.c"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment