diff options
author | David Malcolm <dmalcolm@redhat.com> | 2020-02-17 03:06:14 -0500 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2020-02-17 20:18:03 -0500 |
commit | d8cde6f9c223f1b6d4f4e4e07088f08a629b7c2a (patch) | |
tree | 275bdf0203735282e45a0b56640c5cad3b1bca3a /gcc/analyzer | |
parent | 1ee98e41383e2c76572c4cbc9a526e9ae63115a2 (diff) | |
download | gcc-d8cde6f9c223f1b6d4f4e4e07088f08a629b7c2a.zip gcc-d8cde6f9c223f1b6d4f4e4e07088f08a629b7c2a.tar.gz gcc-d8cde6f9c223f1b6d4f4e4e07088f08a629b7c2a.tar.bz2 |
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.
Diffstat (limited to 'gcc/analyzer')
-rw-r--r-- | gcc/analyzer/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/analyzer/region-model.cc | 2 |
2 files changed, 9 insertions, 0 deletions
diff --git a/gcc/analyzer/ChangeLog b/gcc/analyzer/ChangeLog index d669c98..f9fd80c 100644 --- a/gcc/analyzer/ChangeLog +++ b/gcc/analyzer/ChangeLog @@ -1,5 +1,12 @@ 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 * engine.cc (impl_region_model_context::on_unknown_tree_code): New. diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index b67660c..deb2015 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -6693,6 +6693,8 @@ region_model::get_fndecl_for_call (const gcall *call, if (code) { tree fn_decl = code->get_tree_for_child_region (fn_rid); + if (!fn_decl) + return NULL_TREE; const cgraph_node *ultimate_node = cgraph_node::get (fn_decl)->ultimate_alias_target (); if (ultimate_node) |