public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] analyzer: fix ICE on non-pointer longjmp [PR97233]
@ 2020-09-28 23:55 David Malcolm
  0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2020-09-28 23:55 UTC (permalink / raw)
  To: gcc-patches

Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to master as r11-3512-g01eabbeadb645959d5dcb0f00f41c3565a8f54f1.

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                | 5 ++++-
 gcc/analyzer/engine.cc                  | 1 +
 gcc/testsuite/gcc.dg/analyzer/pr97233.c | 8 ++++++++
 3 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/analyzer/pr97233.c

diff --git a/gcc/analyzer/analyzer.cc b/gcc/analyzer/analyzer.cc
index 82d487858dc..c792dc38f27 100644
--- a/gcc/analyzer/analyzer.cc
+++ b/gcc/analyzer/analyzer.cc
@@ -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;
 }
diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc
index aa43e4cb808..84eaa8415da 100644
--- a/gcc/analyzer/engine.cc
+++ b/gcc/analyzer/engine.cc
@@ -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
index 00000000000..86930aa5872
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr97233.c
@@ -0,0 +1,8 @@
+void
+longjmp (__SIZE_TYPE__, int);
+
+void
+e7 (__SIZE_TYPE__ gr)
+{
+  longjmp (gr, 1);
+}
-- 
2.26.2


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-28 23:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-28 23:55 [committed] analyzer: fix ICE on non-pointer longjmp [PR97233] David Malcolm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).