From df5c389e8f20de804f8eecffe2e4829687b0d5b7 Mon Sep 17 00:00:00 2001 From: kenner Date: Fri, 25 Jan 2002 20:45:48 +0000 Subject: [PATCH] * builtins.c (expand_builtin_strncpy): Use integer_zerop instead of compare_tree_int. (expand_builtin_strncat): Likewise. * c-decl.c (finish_struct): Use tree_low_cst. * tree.h (compare_tree_int): Arg is unsigned HOST_WIDE_INT. * tree.c (compare_tree_int): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@49222 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 11 ++++++++++- gcc/builtins.c | 15 ++++++++------- gcc/c-decl.c | 11 +++++------ gcc/tree.c | 2 +- gcc/tree.h | 3 ++- 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bec4e64..713d625 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +Fri Jan 25 08:26:19 2002 Richard Kenner + + * builtins.c (expand_builtin_strncpy): Use integer_zerop instead + of compare_tree_int. + (expand_builtin_strncat): Likewise. + * c-decl.c (finish_struct): Use tree_low_cst. + * tree.h (compare_tree_int): Arg is unsigned HOST_WIDE_INT. + * tree.c (compare_tree_int): Likewise. + 2002-01-25 Ulrich Weigand * reload1.c (eliminate_regs_in_insn): Recognize frame pointer @@ -5,7 +14,7 @@ Fri Jan 25 20:43:56 CET 2002 Jan Hubicka - * df.c (df_ref_create, df_ref_record_1, df_ref_record): Kill BB argument. + * df.c (df_ref_create, df_ref_record_1, df_ref_record): Kill BB arg. * df.h (struct ref): Kill B. (DF_REF_BB, DF_REF_BBNO): Use BLOCK_FOR_INSN. diff --git a/gcc/builtins.c b/gcc/builtins.c index 9d308ae..0747806 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -2062,7 +2062,7 @@ expand_builtin_strncpy (arglist, target, mode) return 0; /* If the len parameter is zero, return the dst parameter. */ - if (compare_tree_int (len, 0) == 0) + if (integer_zerop (len)) { /* Evaluate and ignore the src argument in case it has side-effects. */ @@ -2279,10 +2279,11 @@ expand_builtin_memcmp (exp, arglist, target, mode) /* If all arguments are constant, and the value of len is not greater than the lengths of arg1 and arg2, evaluate at compile-time. */ if (host_integerp (len, 1) && p1 && p2 - && compare_tree_int (len, strlen (p1)+1) <= 0 - && compare_tree_int (len, strlen (p2)+1) <= 0) + && compare_tree_int (len, strlen (p1) + 1) <= 0 + && compare_tree_int (len, strlen (p2) + 1) <= 0) { const int r = memcmp (p1, p2, tree_low_cst (len, 1)); + return (r < 0 ? constm1_rtx : (r > 0 ? const1_rtx : const0_rtx)); } @@ -2607,7 +2608,7 @@ expand_builtin_strncat (arglist, target, mode) /* If the requested length is zero, or the src parameter string length is zero, return the dst parameter. */ - if ((TREE_CODE (len) == INTEGER_CST && compare_tree_int (len, 0) == 0) + if ((TREE_CODE (len) == INTEGER_CST && integer_zerop (len)) || (p && *p == '\0')) { /* Evaluate and ignore the src and len parameters in case @@ -2622,9 +2623,9 @@ expand_builtin_strncat (arglist, target, mode) if (TREE_CODE (len) == INTEGER_CST && p && compare_tree_int (len, strlen (p)) >= 0) { - tree newarglist = - tree_cons (NULL_TREE, dst, build_tree_list (NULL_TREE, src)), - fn = built_in_decls[BUILT_IN_STRCAT]; + tree newarglist + = tree_cons (NULL_TREE, dst, build_tree_list (NULL_TREE, src)); + tree fn = built_in_decls[BUILT_IN_STRCAT]; /* If the replacement _DECL isn't initialized, don't do the transformation. */ diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 206c7718..2d21a43 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -5693,11 +5693,10 @@ finish_struct (t, fieldlist, attributes) field widths. */ if (DECL_INITIAL (x)) { - int max_width; - if (TYPE_MAIN_VARIANT (TREE_TYPE (x)) == c_bool_type_node) - max_width = CHAR_TYPE_SIZE; - else - max_width = TYPE_PRECISION (TREE_TYPE (x)); + int max_width + = (TYPE_MAIN_VARIANT (TREE_TYPE (x)) == c_bool_type_node + ? CHAR_TYPE_SIZE : TYPE_PRECISION (TREE_TYPE (x))); + if (tree_int_cst_sgn (DECL_INITIAL (x)) < 0) error_with_decl (x, "negative width in bit-field `%s'"); else if (0 < compare_tree_int (DECL_INITIAL (x), max_width)) @@ -5708,7 +5707,7 @@ finish_struct (t, fieldlist, attributes) { /* The test above has assured us that TREE_INT_CST_HIGH is 0. */ unsigned HOST_WIDE_INT width - = TREE_INT_CST_LOW (DECL_INITIAL (x)); + = tree_low_cst (DECL_INITIAL (x), 1); if (TREE_CODE (TREE_TYPE (x)) == ENUMERAL_TYPE && (width < min_precision (TYPE_MIN_VALUE (TREE_TYPE (x)), diff --git a/gcc/tree.c b/gcc/tree.c index adaa9ab..86c0cd0 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -3633,7 +3633,7 @@ simple_cst_equal (t1, t2) int compare_tree_int (t, u) tree t; - unsigned int u; + unsigned HOST_WIDE_INT u; { if (tree_int_cst_sgn (t) < 0) return -1; diff --git a/gcc/tree.h b/gcc/tree.h index adcb0f2..a277bad 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -2888,7 +2888,8 @@ extern void preserve_data PARAMS ((void)); extern int object_permanent_p PARAMS ((tree)); extern int type_precision PARAMS ((tree)); extern int simple_cst_equal PARAMS ((tree, tree)); -extern int compare_tree_int PARAMS ((tree, unsigned int)); +extern int compare_tree_int PARAMS ((tree, + unsigned HOST_WIDE_INT)); extern int type_list_equal PARAMS ((tree, tree)); extern int chain_member PARAMS ((tree, tree)); extern int chain_member_purpose PARAMS ((tree, tree)); -- 2.7.4