diff mbox series

Add more test coverage to selftest::test_location_wrappers

Message ID 1516650766-15076-1-git-send-email-dmalcolm@redhat.com
State New
Headers show
Series Add more test coverage to selftest::test_location_wrappers | expand

Commit Message

David Malcolm Jan. 22, 2018, 7:52 p.m. UTC
This patch adds a few extra assertions to selftest::test_location_wrappers.

Successfully bootstrapped&regrtested on x86_64-pc-linux-gnu.
OK for trunk?

gcc/ChangeLog:
	* tree.c (selftest::test_location_wrappers): Add more test
	coverage.
---
 gcc/tree.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Richard Biener Jan. 23, 2018, 10:27 a.m. UTC | #1
On Mon, Jan 22, 2018 at 8:52 PM, David Malcolm <dmalcolm@redhat.com> wrote:
> This patch adds a few extra assertions to selftest::test_location_wrappers.
>
> Successfully bootstrapped&regrtested on x86_64-pc-linux-gnu.
> OK for trunk?

Ok.

> gcc/ChangeLog:
>         * tree.c (selftest::test_location_wrappers): Add more test
>         coverage.
> ---
>  gcc/tree.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/gcc/tree.c b/gcc/tree.c
> index b3e93b8..c5baf08 100644
> --- a/gcc/tree.c
> +++ b/gcc/tree.c
> @@ -14490,6 +14490,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));
> @@ -14500,6 +14502,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));
> --
> 1.8.5.3
>
diff mbox series

Patch

diff --git a/gcc/tree.c b/gcc/tree.c
index b3e93b8..c5baf08 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -14490,6 +14490,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));
@@ -14500,6 +14502,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));