r16-7560-gf310e487e1a5f0 bulletproofed
unaryop_svalue::maybe_get_value_range against sloppy use of types in the
analyzer.

Do the same for binary ops.

Successfully bootstrapped & regrtested on aarch64-unknown-linux-gnu.
Pushed to trunk as r17-608-g8354a70739419d.

gcc/analyzer/ChangeLog:
        PR analyzer/124104
        * svalue.cc (binop_svalue::maybe_get_value_range_1): Bail out for
        incompatible types.

Signed-off-by: David Malcolm <[email protected]>
---
 gcc/analyzer/svalue.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/analyzer/svalue.cc b/gcc/analyzer/svalue.cc
index 1c0041ab75b..2df7627dd30 100644
--- a/gcc/analyzer/svalue.cc
+++ b/gcc/analyzer/svalue.cc
@@ -1748,7 +1748,8 @@ binop_svalue::maybe_get_value_range_1 (value_range &out) 
const
     if (m_arg1->maybe_get_value_range (rhs))
       {
        range_op_handler handler (m_op);
-       if (handler)
+       if (handler
+           && handler.operand_check_p (type, lhs.type (), rhs.type ()))
          {
            out.set_range_class (type);
            if (handler.fold_range (out, get_type (), lhs, rhs))
-- 
2.52.0

Reply via email to