gcc/analyzer/ChangeLog:
PR analyzer/124104
* svalue.cc (unaryop_svalue::maybe_get_value_range): Bail out for
incompatible types.
gcc/testsuite/ChangeLog:
PR analyzer/124104
* c-c++-common/analyzer/casts-3.c: New test.
* gcc.dg/analyzer/ice-pr124104.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
if (m_arg->maybe_get_value_range (arg_vr))
{
range_op_handler handler (m_op);
- if (handler)
+ if (handler
+ && handler.operand_check_p (type, arg_vr.type (), type))
{
/* For unary ops, range_op_hander::fold_range expects
a VARYING of the unknown value as the 2nd operand. */
--- /dev/null
+#include "analyzer-decls.h"
+
+static int __attribute__((noipa))
+as_int (unsigned char c)
+{
+ return c;
+}
+
+void test_1 (unsigned char c)
+{
+ __analyzer_eval (as_int (c) >= 0); /* { dg-warning "TRUE" } */
+ __analyzer_eval (as_int (c) < 256); /* { dg-warning "TRUE" } */
+}
--- /dev/null
+short s;
+
+short
+foo()
+{
+ short t = 0;
+ __atomic_fetch_sub(&t, s, 0);
+ return t ?: 5;
+}