analyzer: fix ICE on METHOD_TYPE (PR 93212)

Message ID 20200110015800.27045-1-dmalcolm@redhat.com
State New
Headers show
Series
  • analyzer: fix ICE on METHOD_TYPE (PR 93212)
Related show

Commit Message

David Malcolm Jan. 10, 2020, 1:58 a.m.
PR analyzer/93212 reports an ICE when attempting to use -fanalyzer
on a C++ source file.  That isn't supported yet, but the fix is
trivial (handling METHOD_TYPE as well as FUNCTION_TYPE).

Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to the dmalcolm/analyzer branch on the GCC git mirror.

gcc/analyzer/ChangeLog:
	PR analyzer/93212
	* region-model.cc (make_region_for_type): Use
	FUNC_OR_METHOD_TYPE_P rather than comparing against FUNCTION_TYPE.
	* region-model.h (function_region::function_region): Likewise.
---
 gcc/analyzer/region-model.cc | 2 +-
 gcc/analyzer/region-model.h  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

-- 
2.21.0

Patch

diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc
index cebb1d7127a..ab52fe7cf31 100644
--- a/gcc/analyzer/region-model.cc
+++ b/gcc/analyzer/region-model.cc
@@ -5951,7 +5951,7 @@  make_region_for_type (region_id parent_rid, tree type)
   if (TREE_CODE (type) == UNION_TYPE)
     return new union_region (parent_rid, type);
 
-  if (TREE_CODE (type) == FUNCTION_TYPE)
+  if (FUNC_OR_METHOD_TYPE_P (type))
     return new function_region (parent_rid, type);
 
   /* If we have a void *, make a new symbolic region.  */
diff --git a/gcc/analyzer/region-model.h b/gcc/analyzer/region-model.h
index b3b33452327..883c4608474 100644
--- a/gcc/analyzer/region-model.h
+++ b/gcc/analyzer/region-model.h
@@ -1210,7 +1210,7 @@  public:
   function_region (region_id parent_rid, tree type)
   : map_region (parent_rid, type)
   {
-    gcc_assert (TREE_CODE (type) == FUNCTION_TYPE);
+    gcc_assert (FUNC_OR_METHOD_TYPE_P (type));
   }
   function_region (const function_region &other)
   : map_region (other)