analyzer: fix ICE on non-pointer longjmp [PR97233]
authorDavid Malcolm <dmalcolm@redhat.com>
Mon, 28 Sep 2020 19:42:31 +0000 (15:42 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Mon, 28 Sep 2020 23:50:24 +0000 (19:50 -0400)
gcc/analyzer/ChangeLog:
PR analyzer/97233
* analyzer.cc (is_longjmp_call_p): Require the initial argument
to be a pointer.
* engine.cc (exploded_node::on_longjmp): Likewise.

gcc/testsuite/ChangeLog:
PR analyzer/97233
* gcc.dg/analyzer/pr97233.c: New test.

gcc/analyzer/analyzer.cc
gcc/analyzer/engine.cc
gcc/testsuite/gcc.dg/analyzer/pr97233.c [new file with mode: 0644]

index 82d4878..c792dc3 100644 (file)
@@ -218,7 +218,10 @@ is_longjmp_call_p (const gcall *call)
 {
   if (is_special_named_call_p (call, "longjmp", 2)
       || is_special_named_call_p (call, "siglongjmp", 2))
-    return true;
+    /* exploded_node::on_longjmp requires a pointer for the initial
+       argument.  */
+    if (POINTER_TYPE_P (TREE_TYPE (gimple_call_arg (call, 0))))
+      return true;
 
   return false;
 }
index aa43e4c..84eaa84 100644 (file)
@@ -1277,6 +1277,7 @@ exploded_node::on_longjmp (exploded_graph &eg,
                           region_model_context *ctxt) const
 {
   tree buf_ptr = gimple_call_arg (longjmp_call, 0);
+  gcc_assert (POINTER_TYPE_P (TREE_TYPE (buf_ptr)));
 
   region_model *new_region_model = new_state->m_region_model;
   const svalue *buf_ptr_sval = new_region_model->get_rvalue (buf_ptr, ctxt);
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr97233.c b/gcc/testsuite/gcc.dg/analyzer/pr97233.c
new file mode 100644 (file)
index 0000000..86930aa
--- /dev/null
@@ -0,0 +1,8 @@
+void
+longjmp (__SIZE_TYPE__, int);
+
+void
+e7 (__SIZE_TYPE__ gr)
+{
+  longjmp (gr, 1);
+}