From: David Malcolm Date: Sat, 12 Sep 2020 13:28:05 +0000 (-0400) Subject: analyzer: fix ICE on setjmp with non-pointer-type [PR97029] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=35e3f0829d8e9cdc7ea19917c9f3a7add3f14847;p=gcc.git analyzer: fix ICE on setjmp with non-pointer-type [PR97029] gcc/analyzer/ChangeLog: PR analyzer/97029 * analyzer.cc (is_setjmp_call_p): Require the initial arg to be a pointer. * region-model.cc (region_model::deref_rvalue): Assert that the svalue is of pointer type. gcc/testsuite/ChangeLog: * gcc.dg/analyzer/pr97029.c: New test. --- diff --git a/gcc/analyzer/analyzer.cc b/gcc/analyzer/analyzer.cc index 814f6248992..82d487858dc 100644 --- a/gcc/analyzer/analyzer.cc +++ b/gcc/analyzer/analyzer.cc @@ -204,7 +204,9 @@ is_setjmp_call_p (const gcall *call) { if (is_special_named_call_p (call, "setjmp", 1) || is_special_named_call_p (call, "sigsetjmp", 2)) - return true; + /* region_model::on_setjmp requires a pointer. */ + if (POINTER_TYPE_P (TREE_TYPE (gimple_call_arg (call, 0)))) + return true; return false; } diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index 75f4eae3083..d53272e4332 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -1446,6 +1446,7 @@ region_model::region_exists_p (const region *reg) const /* Get a region for referencing PTR_SVAL, creating a region if need be, and potentially generating warnings via CTXT. + PTR_SVAL must be of pointer type. PTR_TREE if non-NULL can be used when emitting diagnostics. */ const region * @@ -1453,6 +1454,7 @@ region_model::deref_rvalue (const svalue *ptr_sval, tree ptr_tree, region_model_context *ctxt) { gcc_assert (ptr_sval); + gcc_assert (POINTER_TYPE_P (ptr_sval->get_type ())); /* If we're dereferencing PTR_SVAL, assume that it is non-NULL; add this as a constraint. This suppresses false positives from diff --git a/gcc/testsuite/gcc.dg/analyzer/pr97029.c b/gcc/testsuite/gcc.dg/analyzer/pr97029.c new file mode 100644 index 00000000000..ff83ad4d56e --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/pr97029.c @@ -0,0 +1,7 @@ +struct vj {}; + +void +setjmp (struct vj pl) +{ + setjmp (pl); +}