aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2020-08-19 13:21:47 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2020-08-19 15:27:09 -0400
commit23ebfda0e352fa0a92c6b012458ecb65505a135f (patch)
treeafc50b41b174d82e50b13475da1fc913fff73626
parentfc02b568e2cd3f6a28d4b7c1063bbf8842c89aad (diff)
downloadgcc-23ebfda0e352fa0a92c6b012458ecb65505a135f.zip
gcc-23ebfda0e352fa0a92c6b012458ecb65505a135f.tar.gz
gcc-23ebfda0e352fa0a92c6b012458ecb65505a135f.tar.bz2
analyzer: fix ICE on deref_rvalue on SK_COMPOUND [PR96643]
gcc/analyzer/ChangeLog: PR analyzer/96643 * region-model.cc (region_model::deref_rvalue): Rather than attempting to handle all svalue kinds in the switch, only cover the special cases, and move symbolic-region handling to after the switch, thus implicitly handling the missing case SK_COMPOUND. gcc/testsuite/ChangeLog: PR analyzer/96643 * g++.dg/analyzer/pr96643.C: New test.
-rw-r--r--gcc/analyzer/region-model.cc26
-rw-r--r--gcc/testsuite/g++.dg/analyzer/pr96643.C26
2 files changed, 31 insertions, 21 deletions
diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc
index 5b08e48..8a5e74e 100644
--- a/gcc/analyzer/region-model.cc
+++ b/gcc/analyzer/region-model.cc
@@ -1369,7 +1369,7 @@ region_model::deref_rvalue (const svalue *ptr_sval, tree ptr_tree,
switch (ptr_sval->get_kind ())
{
default:
- gcc_unreachable ();
+ break;
case SK_REGION:
{
@@ -1395,17 +1395,10 @@ region_model::deref_rvalue (const svalue *ptr_sval, tree ptr_tree,
return m_mgr->get_offset_region (parent_region, type, offset);
}
default:
- goto create_symbolic_region;
+ break;
}
}
-
- case SK_CONSTANT:
- case SK_INITIAL:
- case SK_UNARYOP:
- case SK_SUB:
- case SK_WIDENING:
- case SK_CONJURED:
- goto create_symbolic_region;
+ break;
case SK_POISONED:
{
@@ -1425,20 +1418,11 @@ region_model::deref_rvalue (const svalue *ptr_sval, tree ptr_tree,
ctxt->warn (new poisoned_value_diagnostic (ptr, pkind));
}
}
- goto create_symbolic_region;
}
-
- case SK_UNKNOWN:
- {
- create_symbolic_region:
- return m_mgr->get_symbolic_region (ptr_sval);
- }
-
- case SK_SETJMP:
- goto create_symbolic_region;
+ break;
}
- gcc_unreachable ();
+ return m_mgr->get_symbolic_region (ptr_sval);
}
/* Set the value of the region given by LHS_REG to the value given
diff --git a/gcc/testsuite/g++.dg/analyzer/pr96643.C b/gcc/testsuite/g++.dg/analyzer/pr96643.C
new file mode 100644
index 0000000..2d0a248
--- /dev/null
+++ b/gcc/testsuite/g++.dg/analyzer/pr96643.C
@@ -0,0 +1,26 @@
+/* { dg-additional-options "-O1" } */
+
+int l0;
+
+class qv {
+public:
+ int operator[] (int b1) const { return k2[b1]; }
+
+private:
+ int *k2;
+};
+
+class g0 {
+ qv nf, v6;
+
+ void
+ iq ();
+};
+
+void
+g0::iq ()
+{
+ for (;;)
+ if (nf[0] == 0)
+ ++l0;
+}