diff mbox

[1/4] Use tree_to_uhwi with an inlined tree_fits_uhwi_p test

Message ID 87txf8obcl.fsf@talisman.default
State New
Headers show

Commit Message

Richard Sandiford Nov. 19, 2013, 11:54 a.m. UTC
check_function_arguments_recurse has an assert that is equivalent
to tree_fits_uhwi_p.  The extraction can then use tree_to_uhwi.

Asserting here makes the intent obvious, but tree_to_uhwi also asserts
for the same thing, so an alternative would be to use tree_to_uhwi on
its own.

Thanks,
Richard


gcc/c-family/
2013-11-19  Kenneth Zadeck  <zadeck@naturalbridge.com>

	* c-common.c (check_function_arguments_recurse): Use tree_fits_uhwi_p
	and tree_to_uhwi.

Comments

Richard Biener Nov. 20, 2013, 9:44 a.m. UTC | #1
On Tue, Nov 19, 2013 at 12:54 PM, Richard Sandiford
<rdsandiford@googlemail.com> wrote:
> check_function_arguments_recurse has an assert that is equivalent
> to tree_fits_uhwi_p.  The extraction can then use tree_to_uhwi.
>
> Asserting here makes the intent obvious, but tree_to_uhwi also asserts
> for the same thing, so an alternative would be to use tree_to_uhwi on
> its own.

Please do that.  Ok with this change.

Thanks,
Richard.

> Thanks,
> Richard
>
>
> gcc/c-family/
> 2013-11-19  Kenneth Zadeck  <zadeck@naturalbridge.com>
>
>         * c-common.c (check_function_arguments_recurse): Use tree_fits_uhwi_p
>         and tree_to_uhwi.
>
> Index: gcc/c-family/c-common.c
> ===================================================================
> --- gcc/c-family/c-common.c     2013-11-19 10:53:54.965643984 +0000
> +++ gcc/c-family/c-common.c     2013-11-19 11:08:41.797920627 +0000
> @@ -9209,10 +9209,9 @@ check_function_arguments_recurse (void (
>                to be valid.  */
>             format_num_expr = TREE_VALUE (TREE_VALUE (attrs));
>
> -           gcc_assert (TREE_CODE (format_num_expr) == INTEGER_CST
> -                       && !TREE_INT_CST_HIGH (format_num_expr));
> +           gcc_assert (tree_fits_uhwi_p (format_num_expr));
>
> -           format_num = TREE_INT_CST_LOW (format_num_expr);
> +           format_num = tree_to_uhwi (format_num_expr);
>
>             for (inner_arg = first_call_expr_arg (param, &iter), i = 1;
>                  inner_arg != 0;
diff mbox

Patch

Index: gcc/c-family/c-common.c
===================================================================
--- gcc/c-family/c-common.c	2013-11-19 10:53:54.965643984 +0000
+++ gcc/c-family/c-common.c	2013-11-19 11:08:41.797920627 +0000
@@ -9209,10 +9209,9 @@  check_function_arguments_recurse (void (
 	       to be valid.  */
 	    format_num_expr = TREE_VALUE (TREE_VALUE (attrs));
 
-	    gcc_assert (TREE_CODE (format_num_expr) == INTEGER_CST
-			&& !TREE_INT_CST_HIGH (format_num_expr));
+	    gcc_assert (tree_fits_uhwi_p (format_num_expr));
 
-	    format_num = TREE_INT_CST_LOW (format_num_expr);
+	    format_num = tree_to_uhwi (format_num_expr);
 
 	    for (inner_arg = first_call_expr_arg (param, &iter), i = 1;
 		 inner_arg != 0;