aboutsummaryrefslogtreecommitdiff
path: root/gcc/analyzer/store.h
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2020-08-31 09:00:23 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2020-08-31 18:28:59 -0400
commit18056e45db1c75aa209fa9a756395ddceb867a88 (patch)
tree0a2207a90419a73af0bcf0086cb1c3a6a45d35a7 /gcc/analyzer/store.h
parent73a2b8dd17dbc02c0c7e6286e90f17833aa50906 (diff)
downloadgcc-18056e45db1c75aa209fa9a756395ddceb867a88.zip
gcc-18056e45db1c75aa209fa9a756395ddceb867a88.tar.gz
gcc-18056e45db1c75aa209fa9a756395ddceb867a88.tar.bz2
analyzer: fix ICE on unknown index in CONSTRUCTOR [PR96860]
PR analyzer/96860 reports an ICE inside CONSTRUCTOR-handling with --param analyzer-max-svalue-depth=0 when attempting to build a binding_map for the CONSTRUCTOR's values. The issue is that when handling (index, value) pairs for initializing an array, the index values for the elements exceeds the svalue complexity limit, and the index is thus treated as unknown, leading to a symbolic rather than concrete offset for each array element. This patch updates the CONSTRUCTOR-handling code so that it can fail, returning an unknown value for the overall value of the constructor for this case, fixing the ICE. gcc/analyzer/ChangeLog: PR analyzer/96860 * region.cc (decl_region::get_svalue_for_constructor): Support apply_ctor_to_region failing. * store.cc (binding_map::apply_ctor_to_region): Add failure handling. (binding_map::apply_ctor_val_to_range): Likewise. (binding_map::apply_ctor_pair_to_child_region): Likewise. Replace assertion that child_base_offset is not symbolic with error handling. * store.h (binding_map::apply_ctor_to_region): Convert return type from void to bool. (binding_map::apply_ctor_val_to_range): Likewise. (binding_map::apply_ctor_pair_to_child_region): Likewise. gcc/testsuite/ChangeLog: PR analyzer/96860 * gcc.dg/analyzer/pr96860-1.c: New test. * gcc.dg/analyzer/pr96860-2.c: New test.
Diffstat (limited to 'gcc/analyzer/store.h')
-rw-r--r--gcc/analyzer/store.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/gcc/analyzer/store.h b/gcc/analyzer/store.h
index 0ac9317..83a4310 100644
--- a/gcc/analyzer/store.h
+++ b/gcc/analyzer/store.h
@@ -340,15 +340,15 @@ public:
void dump_to_pp (pretty_printer *pp, bool simple, bool multiline) const;
void dump (bool simple) const;
- void apply_ctor_to_region (const region *parent_reg, tree ctor,
+ bool apply_ctor_to_region (const region *parent_reg, tree ctor,
region_model_manager *mgr);
private:
- void apply_ctor_val_to_range (const region *parent_reg,
+ bool apply_ctor_val_to_range (const region *parent_reg,
region_model_manager *mgr,
tree min_index, tree max_index,
tree val);
- void apply_ctor_pair_to_child_region (const region *parent_reg,
+ bool apply_ctor_pair_to_child_region (const region *parent_reg,
region_model_manager *mgr,
tree index, tree val);