aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2018-01-23 11:05:21 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2018-01-23 11:05:21 +0000
commit02851c8c7f8b04a4a726e3162177a5ea4d19ca36 (patch)
tree132369de3a4bbb66e43b8eb0bbc7b7cfcc7d8d94 /gcc
parent485cf85403386fa44d9746c7f4f449e03760eb01 (diff)
downloadgcc-02851c8c7f8b04a4a726e3162177a5ea4d19ca36.zip
gcc-02851c8c7f8b04a4a726e3162177a5ea4d19ca36.tar.gz
gcc-02851c8c7f8b04a4a726e3162177a5ea4d19ca36.tar.bz2
Add more test coverage to selftest::test_location_wrappers
gcc/ChangeLog: * tree.c (selftest::test_location_wrappers): Add more test coverage. From-SVN: r256979
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/tree.c10
2 files changed, 15 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3a4a97b..a845fef 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2018-01-23 David Malcolm <dmalcolm@redhat.com>
+ * tree.c (selftest::test_location_wrappers): Add more test
+ coverage.
+
+2018-01-23 David Malcolm <dmalcolm@redhat.com>
+
* sbitmap.c (selftest::test_set_range): Fix memory leaks.
(selftest::test_bit_in_range): Likewise.
diff --git a/gcc/tree.c b/gcc/tree.c
index 452d385..63a29f4 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -14492,6 +14492,8 @@ test_location_wrappers ()
{
location_t loc = BUILTINS_LOCATION;
+ ASSERT_EQ (NULL_TREE, maybe_wrap_with_location (NULL_TREE, loc));
+
/* Wrapping a constant. */
tree int_cst = build_int_cst (integer_type_node, 42);
ASSERT_FALSE (CAN_HAVE_LOCATION_P (int_cst));
@@ -14502,6 +14504,14 @@ test_location_wrappers ()
ASSERT_EQ (loc, EXPR_LOCATION (wrapped_int_cst));
ASSERT_EQ (int_cst, tree_strip_any_location_wrapper (wrapped_int_cst));
+ /* We shouldn't add wrapper nodes for UNKNOWN_LOCATION. */
+ ASSERT_EQ (int_cst, maybe_wrap_with_location (int_cst, UNKNOWN_LOCATION));
+
+ /* We shouldn't add wrapper nodes for nodes that CAN_HAVE_LOCATION_P. */
+ tree cast = build1 (NOP_EXPR, char_type_node, int_cst);
+ ASSERT_TRUE (CAN_HAVE_LOCATION_P (cast));
+ ASSERT_EQ (cast, maybe_wrap_with_location (cast, loc));
+
/* Wrapping a STRING_CST. */
tree string_cst = build_string (4, "foo");
ASSERT_FALSE (CAN_HAVE_LOCATION_P (string_cst));