[committed] analyzer: fix overeager sharing of bounded_range instances [PR102662]
Commit Message
This was leading to an assertion failure ICE on a switch stmt when using
-fstrict-enums, due to erroneously reusing a range involving one enum
with a range involving a different enum.
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to trunk as r12-5307-ge1c0c908f85816240b685a5be4f0e5a0e6634979.
gcc/analyzer/ChangeLog:
PR analyzer/102662
* constraint-manager.cc (bounded_range::operator==): Require the
types to be the same for equality.
gcc/testsuite/ChangeLog:
PR analyzer/102662
* g++.dg/analyzer/pr102662.C: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
---
gcc/analyzer/constraint-manager.cc | 4 ++-
gcc/testsuite/g++.dg/analyzer/pr102662.C | 39 ++++++++++++++++++++++++
2 files changed, 42 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/g++.dg/analyzer/pr102662.C
@@ -432,7 +432,9 @@ bounded_range::intersects_p (const bounded_range &other,
bool
bounded_range::operator== (const bounded_range &other) const
{
- return (tree_int_cst_equal (m_lower, other.m_lower)
+ return (TREE_TYPE (m_lower) == TREE_TYPE (other.m_lower)
+ && TREE_TYPE (m_upper) == TREE_TYPE (other.m_upper)
+ && tree_int_cst_equal (m_lower, other.m_lower)
&& tree_int_cst_equal (m_upper, other.m_upper));
}
new file mode 100644
@@ -0,0 +1,39 @@
+/* { dg-additional-options "-fstrict-enums" } */
+
+enum OpCode {
+ OP_MOVE,
+ OP_LOADK,
+ OP_LOADBOOL,
+ OP_LOADNIL,
+ OP_GETUPVAL,
+ OP_SETUPVAL
+};
+
+enum OpArg {
+ OpArgN,
+ OpArgU,
+ OpArgR,
+ OpArgK
+};
+
+void
+symbexec_lastpc (enum OpCode symbexec_lastpc_op, enum OpArg luaP_opmodes)
+{
+ switch (luaP_opmodes)
+ {
+ case OpArgN:
+ case OpArgK:
+ {
+ switch (symbexec_lastpc_op)
+ {
+ case OP_LOADNIL:
+ case OP_SETUPVAL:
+ break;
+ default:
+ break;
+ }
+ }
+ default:
+ break;
+ }
+}