aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2021-06-17 13:40:05 -0400
committerAndrew MacLeod <amacleod@redhat.com>2021-06-22 08:11:46 -0400
commitca1f9f22854049d6f9cab5b4bfbc46edbcb5c990 (patch)
treefef07696dcac93fec9c6566af7c8195fd999bda6 /gcc
parent0f7ccc063a42407f91fa52a54cc480950a45e75c (diff)
downloadgcc-ca1f9f22854049d6f9cab5b4bfbc46edbcb5c990.zip
gcc-ca1f9f22854049d6f9cab5b4bfbc46edbcb5c990.tar.gz
gcc-ca1f9f22854049d6f9cab5b4bfbc46edbcb5c990.tar.bz2
Add relational self-tests.
* range-op.cc (range_relational_tests): New. (range_op_tests): Call range_relational_tests.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/range-op.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 92b314d..1692a09 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -4244,6 +4244,30 @@ range_op_bitwise_and_tests ()
ASSERT_FALSE (res.contains_p (INT (0)));
}
+static void
+range_relational_tests ()
+{
+ int_range<2> lhs (unsigned_char_type_node);
+ int_range<2> op1 (UCHAR (8), UCHAR (10));
+ int_range<2> op2 (UCHAR (20), UCHAR (20));
+
+ // Never wrapping additions mean LHS > OP1.
+ tree_code code = op_plus.lhs_op1_relation (lhs, op1, op2);
+ ASSERT_TRUE (code == GT_EXPR);
+
+ // Most wrapping additions mean nothing...
+ op1 = int_range<2> (UCHAR (8), UCHAR (10));
+ op2 = int_range<2> (UCHAR (0), UCHAR (255));
+ code = op_plus.lhs_op1_relation (lhs, op1, op2);
+ ASSERT_TRUE (code == VREL_NONE);
+
+ // However, always wrapping additions mean LHS < OP1.
+ op1 = int_range<2> (UCHAR (1), UCHAR (255));
+ op2 = int_range<2> (UCHAR (255), UCHAR (255));
+ code = op_plus.lhs_op1_relation (lhs, op1, op2);
+ ASSERT_TRUE (code == LT_EXPR);
+}
+
void
range_op_tests ()
{
@@ -4251,6 +4275,7 @@ range_op_tests ()
range_op_lshift_tests ();
range_op_bitwise_and_tests ();
range_op_cast_tests ();
+ range_relational_tests ();
}
} // namespace selftest