mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
analyzer: fix ICE due to sloppy types in unaryop_svalue [PR124104]
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>
This commit is contained in:
@@ -1585,7 +1585,8 @@ unaryop_svalue::maybe_get_value_range (value_range &out) const
|
||||
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. */
|
||||
|
||||
13
gcc/testsuite/c-c++-common/analyzer/casts-3.c
Normal file
13
gcc/testsuite/c-c++-common/analyzer/casts-3.c
Normal file
@@ -0,0 +1,13 @@
|
||||
#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" } */
|
||||
}
|
||||
9
gcc/testsuite/gcc.dg/analyzer/ice-pr124104.c
Normal file
9
gcc/testsuite/gcc.dg/analyzer/ice-pr124104.c
Normal file
@@ -0,0 +1,9 @@
|
||||
short s;
|
||||
|
||||
short
|
||||
foo()
|
||||
{
|
||||
short t = 0;
|
||||
__atomic_fetch_sub(&t, s, 0);
|
||||
return t ?: 5;
|
||||
}
|
||||
Reference in New Issue
Block a user