diff options
author | David Malcolm <dmalcolm@redhat.com> | 2020-09-12 09:28:05 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2020-09-14 12:26:24 -0400 |
commit | 35e3f0829d8e9cdc7ea19917c9f3a7add3f14847 (patch) | |
tree | ec301c5842cac19f59dcc340c4f431702a21c395 | |
parent | a7d8dcdf2f3cf9a801e655f2eec3967a3a3ba666 (diff) | |
download | gcc-35e3f0829d8e9cdc7ea19917c9f3a7add3f14847.zip gcc-35e3f0829d8e9cdc7ea19917c9f3a7add3f14847.tar.gz gcc-35e3f0829d8e9cdc7ea19917c9f3a7add3f14847.tar.bz2 |
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.
-rw-r--r-- | gcc/analyzer/analyzer.cc | 4 | ||||
-rw-r--r-- | gcc/analyzer/region-model.cc | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/analyzer/pr97029.c | 7 |
3 files changed, 12 insertions, 1 deletions
diff --git a/gcc/analyzer/analyzer.cc b/gcc/analyzer/analyzer.cc index 814f624..82d4878 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 75f4eae..d53272e 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 0000000..ff83ad4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/pr97029.c @@ -0,0 +1,7 @@ +struct vj {}; + +void +setjmp (struct vj pl) +{ + setjmp (pl); +} |