aboutsummaryrefslogtreecommitdiff
path: root/gcc/analyzer/region-model-manager.cc
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2022-02-14 13:27:45 -0500
committerDavid Malcolm <dmalcolm@redhat.com>2022-02-15 16:34:33 -0500
commit84832cab6e43db7fa10ec53d15f8f8457aa31080 (patch)
tree363d79134859899c598e9c254528b1a16e80be7e /gcc/analyzer/region-model-manager.cc
parent1e2fe6715a949f80c1204ae244baad3cd80ffaf0 (diff)
downloadgcc-84832cab6e43db7fa10ec53d15f8f8457aa31080.zip
gcc-84832cab6e43db7fa10ec53d15f8f8457aa31080.tar.gz
gcc-84832cab6e43db7fa10ec53d15f8f8457aa31080.tar.bz2
analyzer: fix ICE on cast to NULL type [PR104524]
gcc/analyzer/ChangeLog: PR analyzer/104524 * region-model-manager.cc (region_model_manager::maybe_fold_sub_svalue): Only call get_or_create_cast if type is non-NULL. gcc/testsuite/ChangeLog: PR analyzer/104524 * gcc.dg/analyzer/pr104524.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/analyzer/region-model-manager.cc')
-rw-r--r--gcc/analyzer/region-model-manager.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/gcc/analyzer/region-model-manager.cc b/gcc/analyzer/region-model-manager.cc
index d7156c5..917af22 100644
--- a/gcc/analyzer/region-model-manager.cc
+++ b/gcc/analyzer/region-model-manager.cc
@@ -771,7 +771,7 @@ region_model_manager::maybe_fold_sub_svalue (tree type,
if (unary->get_op () == NOP_EXPR
|| unary->get_op () == VIEW_CONVERT_EXPR)
if (tree cst = unary->get_arg ()->maybe_get_constant ())
- if (zerop (cst))
+ if (zerop (cst) && type)
{
const svalue *cst_sval
= get_or_create_constant_svalue (cst);
@@ -786,7 +786,8 @@ region_model_manager::maybe_fold_sub_svalue (tree type,
/* If we have a concrete 1-byte access within the parent region... */
byte_range subregion_bytes (0, 0);
if (subregion->get_relative_concrete_byte_range (&subregion_bytes)
- && subregion_bytes.m_size_in_bytes == 1)
+ && subregion_bytes.m_size_in_bytes == 1
+ && type)
{
/* ...then attempt to get that char from the STRING_CST. */
HOST_WIDE_INT hwi_start_byte