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.
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>
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));
}
--- /dev/null
+/* { 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;
+ }
+}