[committed] analyzer: fix ICE with 'const void *' (PR 93457)

Message ID 20200131223013.13512-1-dmalcolm@redhat.com
State New
Headers show
Series
  • [committed] analyzer: fix ICE with 'const void *' (PR 93457)
Related show

Commit Message

David Malcolm Jan. 31, 2020, 10:30 p.m.
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to master as r10-6386-g6775172431a8e6f0d20ac0c4946d6b5db2f46450.

gcc/analyzer/ChangeLog:
	PR analyzer/93457
	* region-model.cc (make_region_for_type): Use VOID_TYPE_P rather
	than checking against void_type_node.

gcc/testsuite/ChangeLog:
	PR analyzer/93457
	* gcc.dg/analyzer/pr93457.c: New test.
---
 gcc/analyzer/region-model.cc            |  2 +-
 gcc/testsuite/gcc.dg/analyzer/pr93457.c | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/analyzer/pr93457.c

-- 
2.21.0

Patch

diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc
index eb6d8f3cf3a..679479c8b5c 100644
--- a/gcc/analyzer/region-model.cc
+++ b/gcc/analyzer/region-model.cc
@@ -6005,7 +6005,7 @@  make_region_for_type (region_id parent_rid, tree type)
     return new function_region (parent_rid, type);
 
   /* If we have a void *, make a new symbolic region.  */
-  if (type == void_type_node)
+  if (VOID_TYPE_P (type))
     return new symbolic_region (parent_rid, false);
 
   gcc_unreachable ();
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr93457.c b/gcc/testsuite/gcc.dg/analyzer/pr93457.c
new file mode 100644
index 00000000000..b77911ba789
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr93457.c
@@ -0,0 +1,10 @@ 
+/* { dg-do compile } */
+
+void
+p5 (const void *);
+
+void
+s5 (const void *cl)
+{
+  p5 (&cl[1]); /* { dg-warning "dereferencing 'void \\*' pointer" } */
+}