File tree 3 files changed +30
-1
lines changed
regression/ebmc/range_type
3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -6,4 +6,4 @@ range_type8.smv
6
6
^SIGNAL=0$
7
7
--
8
8
--
9
- We do not have type checking for unary minus.
9
+ We do not have solver support for unary minus on ranges .
Original file line number Diff line number Diff line change @@ -84,6 +84,12 @@ class smv_ranget
84
84
85
85
return *this ;
86
86
}
87
+
88
+ // unary minus
89
+ smv_ranget operator -() const
90
+ {
91
+ return smv_ranget{-to, -from};
92
+ }
87
93
};
88
94
89
95
#endif // CPROVER_SMV_RANGE_H
Original file line number Diff line number Diff line change @@ -752,6 +752,29 @@ void smv_typecheckt::typecheck_expr_rec(
752
752
<< " Expected number type for " << to_string (expr);
753
753
}
754
754
}
755
+ else if (expr.id () == ID_unary_minus)
756
+ {
757
+ typecheck_op (expr, dest_type, mode);
758
+
759
+ if (expr.operands ().size () != 1 )
760
+ {
761
+ error ().source_location = expr.find_source_location ();
762
+ error () << " Expected one operand for " << expr.id () << eom;
763
+ throw 0 ;
764
+ }
765
+
766
+ if (dest_type.is_nil ())
767
+ {
768
+ if (expr.type ().id () == ID_range || expr.type ().id () == ID_bool)
769
+ {
770
+ // find proper type for precise arithmetic
771
+ smv_ranget smv_range_op =
772
+ convert_type (to_unary_minus_expr (expr).op ().type ());
773
+ smv_ranget new_range = -smv_range_op;
774
+ new_range.to_type (expr.type ());
775
+ }
776
+ }
777
+ }
755
778
else if (expr.id ()==ID_constant)
756
779
{
757
780
if (expr.type ().id ()==ID_integer)
You can’t perform that action at this time.
0 commit comments