From 09bea5845a50189b093e7fa8d5b840da702197d4 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Wed, 22 Jan 2020 13:08:26 -0500 Subject: [PATCH] analyzer: fix ICE handling void-type (PR 93373) gcc/analyzer/ChangeLog: PR analyzer/93373 * region-model.cc (ASSERT_COMPAT_TYPES): Convert to... (assert_compat_types): ...this, and bail when either type is NULL, or when VOID_TYPE_P (dst_type). (region_model::get_lvalue): Update for above conversion. (region_model::get_rvalue): Likewise. gcc/testsuite/ChangeLog: PR analyzer/93373 * gcc.dg/analyzer/torture/pr93373.c: New test. --- gcc/analyzer/ChangeLog | 9 +++++++++ gcc/analyzer/region-model.cc | 12 ++++++++---- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/analyzer/torture/pr93373.c | 3 +++ 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/analyzer/torture/pr93373.c diff --git a/gcc/analyzer/ChangeLog b/gcc/analyzer/ChangeLog index fa791f70d34..416fc9201d3 100644 --- a/gcc/analyzer/ChangeLog +++ b/gcc/analyzer/ChangeLog @@ -1,3 +1,12 @@ +2020-01-31 David Malcolm + + PR analyzer/93373 + * region-model.cc (ASSERT_COMPAT_TYPES): Convert to... + (assert_compat_types): ...this, and bail when either type is NULL, + or when VOID_TYPE_P (dst_type). + (region_model::get_lvalue): Update for above conversion. + (region_model::get_rvalue): Likewise. + 2020-01-31 David Malcolm PR analyzer/93379 diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index d43aef3a4d7..eb6d8f3cf3a 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -4701,8 +4701,12 @@ region_model::get_lvalue_1 (path_var pv, region_model_context *ctxt) /* Assert that SRC_TYPE can be converted to DST_TYPE as a no-op. */ -#define ASSERT_COMPAT_TYPES(SRC_TYPE, DST_TYPE) \ - gcc_checking_assert (useless_type_conversion_p ((SRC_TYPE), (DST_TYPE))) +static void +assert_compat_types (tree src_type, tree dst_type) +{ + if (src_type && dst_type && !VOID_TYPE_P (dst_type)) + gcc_checking_assert (useless_type_conversion_p (src_type, dst_type)); +} /* Get the id of the region for PV within this region_model, emitting any diagnostics to CTXT. */ @@ -4714,7 +4718,7 @@ region_model::get_lvalue (path_var pv, region_model_context *ctxt) return region_id::null (); region_id result_rid = get_lvalue_1 (pv, ctxt); - ASSERT_COMPAT_TYPES (get_region (result_rid)->get_type (), + assert_compat_types (get_region (result_rid)->get_type (), TREE_TYPE (pv.m_tree)); return result_rid; } @@ -4795,7 +4799,7 @@ region_model::get_rvalue (path_var pv, region_model_context *ctxt) return svalue_id::null (); svalue_id result_sid = get_rvalue_1 (pv, ctxt); - ASSERT_COMPAT_TYPES (get_svalue (result_sid)->get_type (), + assert_compat_types (get_svalue (result_sid)->get_type (), TREE_TYPE (pv.m_tree)); return result_sid; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 556e5fb55da..d13768a16f2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-01-31 David Malcolm + + PR analyzer/93373 + * gcc.dg/analyzer/torture/pr93373.c: New test. + 2020-01-31 Vladimir Makarov PR rtl-optimization/91333 diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/pr93373.c b/gcc/testsuite/gcc.dg/analyzer/torture/pr93373.c new file mode 100644 index 00000000000..c205ee13465 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/torture/pr93373.c @@ -0,0 +1,3 @@ +/* { dg-do compile } + { dg-require-effective-target alloca } */ +#include "../../Warray-bounds-41.c" -- 2.30.2