This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Fix warnings & minor cleanups


These remove some warnings and so some minor cleanups, none of which produce
any functional changes.  Tested on alphaev56.

Mon Sep 10 06:47:35 2001  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* alias.c (clear_reg_alias_info): Use K&R format definition.
	Avoid unsigned warning.
	* builtins.c: Use "unsigned int", not "unsigned".
	(target_char_cast): Use host_integerp and tree_low_cst.
	(expand_builtin_args_info, expand_builtin_frame_address): Likewise.
	(c_strlen): Likewise; OFFSET now HOST_WIDE_INT.
	(c_getstr): Likewise.
	(std_expand_builtin_va_arg): Use int_size_in_bytes.
	(builtin_memcpy_read_str): Avoid unsigned warning.
	(expand_builtin_memcpy): Alignments are unsigned.
	(expand_builtin_strncpy, expand_builtin_memset): Likewise.
	(expand_builtin_expect_jump): Use integer_zerop and integer_onep.
	* predict.c (expensive_function_p): LIMIT now unsigned.
	* resource.c (mark_target_live_regs): Make some vars unsigned.
	* sdbout.c: Use "unsigned int", not "unsigned".
	(MAKE_LINE_SAFE): Add cast to avoid unsigned warning.
	(sdbout_source_line): Likewise.
	(sdbout_record_type_name): Remove "const" for NAME declaration.
	* config/alpha/alpha.c (alpha_expand_block_move): Whitespace fixes.

*** alias.c	2001/09/07 23:25:01	1.139
--- alias.c	2001/09/10 10:39:08
*************** record_base_value (regno, val, invariant
*** 967,976 ****
  
  void
! clear_reg_alias_info (rtx reg)
  {
!   int regno = REGNO (reg);
! 
!   if (regno < reg_known_value_size)
!     reg_known_value[regno] = reg;
  }
  
--- 967,975 ----
  
  void
! clear_reg_alias_info (reg)
!      rtx reg;
  {
!   if (REGNO (reg) < reg_known_value_size)
!     reg_known_value[REGNO (reg)] = reg;
  }
  
*** builtins.c	2001/08/27 17:36:19	1.117
--- builtins.c	2001/09/10 10:39:28
*************** tree built_in_decls[(int) END_BUILTINS];
*** 75,79 ****
  tree (*lang_type_promotes_to) PARAMS ((tree));
  
! static int get_pointer_alignment	PARAMS ((tree, unsigned));
  static tree c_strlen			PARAMS ((tree));
  static const char *c_getstr		PARAMS ((tree));
--- 75,79 ----
  tree (*lang_type_promotes_to) PARAMS ((tree));
  
! static int get_pointer_alignment	PARAMS ((tree, unsigned int));
  static tree c_strlen			PARAMS ((tree));
  static const char *c_getstr		PARAMS ((tree));
*************** static int validate_arglist		PARAMS ((tr
*** 151,155 ****
     But don't return more than MAX_ALIGN no matter what.
     The alignment returned is, by default, the alignment of the thing that
!    EXP points to (if it is not a POINTER_TYPE, 0 is returned).
  
     Otherwise, look at the expression to see if we can do better, i.e., if the
--- 151,155 ----
     But don't return more than MAX_ALIGN no matter what.
     The alignment returned is, by default, the alignment of the thing that
!    EXP points to.  If it is not a POINTER_TYPE, 0 is returned.
  
     Otherwise, look at the expression to see if we can do better, i.e., if the
*************** static int
*** 159,165 ****
  get_pointer_alignment (exp, max_align)
       tree exp;
!      unsigned max_align;
  {
!   unsigned align, inner;
  
    if (TREE_CODE (TREE_TYPE (exp)) != POINTER_TYPE)
--- 159,165 ----
  get_pointer_alignment (exp, max_align)
       tree exp;
!      unsigned int max_align;
  {
!   unsigned int align, inner;
  
    if (TREE_CODE (TREE_TYPE (exp)) != POINTER_TYPE)
*************** c_strlen (src)
*** 232,236 ****
  {
    tree offset_node;
!   int offset, max;
    const char *ptr;
  
--- 232,237 ----
  {
    tree offset_node;
!   HOST_WIDE_INT offset;
!   int max;
    const char *ptr;
  
*************** c_strlen (src)
*** 264,277 ****
  
    /* We have a known offset into the string.  Start searching there for
!      a null character.  */
!   if (offset_node == 0)
      offset = 0;
    else
!     {
!       /* Did we get a long long offset?  If so, punt.  */
!       if (TREE_INT_CST_HIGH (offset_node) != 0)
! 	return 0;
!       offset = TREE_INT_CST_LOW (offset_node);
!     }
  
    /* If the offset is known to be out of bounds, warn, and call strlen at
--- 265,273 ----
  
    /* We have a known offset into the string.  Start searching there for
!      a null character if we can represent it as a single HOST_WIDE_INT.  */
!   if (offset_node == 0 || ! host_integerp (offset_node, 0))
      offset = 0;
    else
!     offset = tree_low_cst (offset_node, 0);
  
    /* If the offset is known to be out of bounds, warn, and call strlen at
*************** c_getstr (src)
*** 300,304 ****
  {
    tree offset_node;
!   int offset, max;
    const char *ptr;
  
--- 296,301 ----
  {
    tree offset_node;
!   HOST_WIDE_INT offset;
!   int max;
    const char *ptr;
  
*************** c_getstr (src)
*** 310,326 ****
    ptr = TREE_STRING_POINTER (src);
  
!   if (!offset_node)
!     offset = 0;
!   else if (TREE_CODE (offset_node) != INTEGER_CST)
      return 0;
-   else
-     {
-       /* Did we get a long long offset?  If so, punt.  */
-       if (TREE_INT_CST_HIGH (offset_node) != 0)
- 	return 0;
-       offset = TREE_INT_CST_LOW (offset_node);
-       if (offset < 0 || offset > max)
- 	return 0;
-     }
  
    return ptr + offset;
--- 307,316 ----
    ptr = TREE_STRING_POINTER (src);
  
!   if (offset_node == 0 || !host_integerp (offset_node, 0))
!     return ptr;
! 
!   offset = tree_low_cst (offset_node, 0);
!   if (offset < 0 || offset > max)
      return 0;
  
    return ptr + offset;
*************** target_char_cast (cst, p)
*** 374,382 ****
    unsigned HOST_WIDE_INT val, hostval;
  
!   if (TREE_CODE (cst) != INTEGER_CST
        || CHAR_TYPE_SIZE > HOST_BITS_PER_WIDE_INT)
      return 1;
  
!   val = TREE_INT_CST_LOW (cst);
    if (CHAR_TYPE_SIZE < HOST_BITS_PER_WIDE_INT)
      val &= (((unsigned HOST_WIDE_INT) 1) << CHAR_TYPE_SIZE) - 1;
--- 364,372 ----
    unsigned HOST_WIDE_INT val, hostval;
  
!   if (!host_integerp (cst, 1)
        || CHAR_TYPE_SIZE > HOST_BITS_PER_WIDE_INT)
      return 1;
  
!   val = tree_low_cst (cst, 1);
    if (CHAR_TYPE_SIZE < HOST_BITS_PER_WIDE_INT)
      val &= (((unsigned HOST_WIDE_INT) 1) << CHAR_TYPE_SIZE) - 1;
*************** builtin_memcpy_read_str (data, offset, m
*** 1790,1794 ****
    const char *str = (const char *) data;
  
!   if (offset + GET_MODE_SIZE (mode) > strlen (str) + 1)
      abort ();  /* Attempt to read past the end of constant string.  */
  
--- 1785,1791 ----
    const char *str = (const char *) data;
  
!   if (offset < 0
!       || ((unsigned HOST_WIDE_INT) offset + GET_MODE_SIZE (mode)
! 	  > strlen (str) + 1))
      abort ();  /* Attempt to read past the end of constant string.  */
  
*************** expand_builtin_memcpy (arglist)
*** 1811,1816 ****
        const char *src_str;
  
!       int src_align = get_pointer_alignment (src, BIGGEST_ALIGNMENT);
!       int dest_align = get_pointer_alignment (dest, BIGGEST_ALIGNMENT);
        rtx dest_mem, src_mem, dest_addr, len_rtx;
  
--- 1809,1815 ----
        const char *src_str;
  
!       unsigned int src_align = get_pointer_alignment (src, BIGGEST_ALIGNMENT);
!       unsigned int dest_align
! 	= get_pointer_alignment (dest, BIGGEST_ALIGNMENT);
        rtx dest_mem, src_mem, dest_addr, len_rtx;
  
*************** expand_builtin_strncpy (arglist, target,
*** 1954,1963 ****
  	{
  	  tree dest = TREE_VALUE (arglist);
! 	  int dest_align = get_pointer_alignment (dest, BIGGEST_ALIGNMENT);
  	  const char *p = c_getstr (TREE_VALUE (TREE_CHAIN (arglist)));
  	  rtx dest_mem;
  
! 	  if (!p || !dest_align || TREE_INT_CST_HIGH (len)
! 	      || !can_store_by_pieces (TREE_INT_CST_LOW (len),
  				       builtin_strncpy_read_str,
  				       (PTR) p, dest_align))
--- 1953,1963 ----
  	{
  	  tree dest = TREE_VALUE (arglist);
! 	  unsigned int dest_align
! 	    = get_pointer_alignment (dest, BIGGEST_ALIGNMENT);
  	  const char *p = c_getstr (TREE_VALUE (TREE_CHAIN (arglist)));
  	  rtx dest_mem;
  
! 	  if (!p || dest_align == 0 || !host_integerp (len, 1)
! 	      || !can_store_by_pieces (tree_low_cst (len, 1),
  				       builtin_strncpy_read_str,
  				       (PTR) p, dest_align))
*************** expand_builtin_strncpy (arglist, target,
*** 1965,1969 ****
  
  	  dest_mem = get_memory_rtx (dest);
! 	  store_by_pieces (dest_mem, TREE_INT_CST_LOW (len),
  			   builtin_strncpy_read_str,
  			   (PTR) p, dest_align);
--- 1965,1969 ----
  
  	  dest_mem = get_memory_rtx (dest);
! 	  store_by_pieces (dest_mem, tree_low_cst (len, 1),
  			   builtin_strncpy_read_str,
  			   (PTR) p, dest_align);
*************** expand_builtin_memset (exp)
*** 2013,2017 ****
        char c;
  
!       int dest_align = get_pointer_alignment (dest, BIGGEST_ALIGNMENT);
        rtx dest_mem, dest_addr, len_rtx;
  
--- 2013,2018 ----
        char c;
  
!       unsigned int dest_align
! 	= get_pointer_alignment (dest, BIGGEST_ALIGNMENT);
        rtx dest_mem, dest_addr, len_rtx;
  
*************** expand_builtin_memset (exp)
*** 2029,2036 ****
        if (c)
  	{
! 	  if (TREE_CODE (len) != INTEGER_CST || TREE_INT_CST_HIGH (len))
  	    return 0;
  	  if (current_function_check_memory_usage
! 	      || !can_store_by_pieces (TREE_INT_CST_LOW (len),
  				       builtin_memset_read_str,
  				       (PTR) &c, dest_align))
--- 2030,2037 ----
        if (c)
  	{
! 	  if (!host_integerp (len, 1))
  	    return 0;
  	  if (current_function_check_memory_usage
! 	      || !can_store_by_pieces (tree_low_cst (len, 1),
  				       builtin_memset_read_str,
  				       (PTR) &c, dest_align))
*************** expand_builtin_memset (exp)
*** 2038,2042 ****
  
  	  dest_mem = get_memory_rtx (dest);
! 	  store_by_pieces (dest_mem, TREE_INT_CST_LOW (len),
  			   builtin_memset_read_str,
  			   (PTR) &c, dest_align);
--- 2039,2043 ----
  
  	  dest_mem = get_memory_rtx (dest);
! 	  store_by_pieces (dest_mem, tree_low_cst (len, 1),
  			   builtin_memset_read_str,
  			   (PTR) &c, dest_align);
*************** expand_builtin_args_info (exp)
*** 2642,2653 ****
    if (arglist != 0)
      {
!       tree arg = TREE_VALUE (arglist);
!       if (TREE_CODE (arg) != INTEGER_CST)
  	error ("argument of `__builtin_args_info' must be constant");
        else
  	{
! 	  int wordnum = TREE_INT_CST_LOW (arg);
  
! 	  if (wordnum < 0 || wordnum >= nwords || TREE_INT_CST_HIGH (arg))
  	    error ("argument of `__builtin_args_info' out of range");
  	  else
--- 2651,2661 ----
    if (arglist != 0)
      {
!       if (!host_integerp (TREE_VALUE (arglist), 0))
  	error ("argument of `__builtin_args_info' must be constant");
        else
  	{
! 	  HOST_WIDE_INT wordnum = tree_low_cst (TREE_VALUE (arglist), 0);
  
! 	  if (wordnum < 0 || wordnum >= nwords)
  	    error ("argument of `__builtin_args_info' out of range");
  	  else
*************** std_expand_builtin_va_arg (valist, type)
*** 2848,2855 ****
        /* Small args are padded downward.  */
  
!       HOST_WIDE_INT adj;
!       adj = TREE_INT_CST_LOW (TYPE_SIZE (type)) / BITS_PER_UNIT;
!       if (rounded_size > align)
! 	adj = rounded_size;
  
        addr_tree = build (PLUS_EXPR, TREE_TYPE (addr_tree), addr_tree,
--- 2859,2864 ----
        /* Small args are padded downward.  */
  
!       HOST_WIDE_INT adj
! 	= rounded_size > align ? rounded_size : int_size_in_bytes (type);
  
        addr_tree = build (PLUS_EXPR, TREE_TYPE (addr_tree), addr_tree,
*************** expand_builtin_frame_address (exp)
*** 3036,3041 ****
      /* Warning about missing arg was already issued.  */
      return const0_rtx;
!   else if (TREE_CODE (TREE_VALUE (arglist)) != INTEGER_CST
! 	   || tree_int_cst_sgn (TREE_VALUE (arglist)) < 0)
      {
        if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_FRAME_ADDRESS)
--- 3046,3050 ----
      /* Warning about missing arg was already issued.  */
      return const0_rtx;
!   else if (! host_integerp (TREE_VALUE (arglist), 1))
      {
        if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_FRAME_ADDRESS)
*************** expand_builtin_frame_address (exp)
*** 3047,3053 ****
    else
      {
!       rtx tem = expand_builtin_return_addr (DECL_FUNCTION_CODE (fndecl),
! 					    TREE_INT_CST_LOW (TREE_VALUE (arglist)),
! 					    hard_frame_pointer_rtx);
  
        /* Some ports cannot access arbitrary stack frames.  */
--- 3056,3063 ----
    else
      {
!       rtx tem
! 	= expand_builtin_return_addr (DECL_FUNCTION_CODE (fndecl),
! 				      tree_low_cst (TREE_VALUE (arglist), 1),
! 				      hard_frame_pointer_rtx);
  
        /* Some ports cannot access arbitrary stack frames.  */
*************** expand_builtin_expect_jump (exp, if_fals
*** 3265,3271 ****
       __builtin_expect (test, 1).  */
    if (TREE_CODE (TREE_TYPE (arg1)) == INTEGER_TYPE
!       && TREE_CODE (arg1) == INTEGER_CST
!       && (TREE_INT_CST_LOW (arg1) == 0 || TREE_INT_CST_LOW (arg1) == 1)
!       && TREE_INT_CST_HIGH (arg1) == 0)
      {
        int j;
--- 3275,3279 ----
       __builtin_expect (test, 1).  */
    if (TREE_CODE (TREE_TYPE (arg1)) == INTEGER_TYPE
!       && (integer_zerop (arg1) || integer_onep (arg1)))
      {
        int j;
*************** expand_builtin_expect_jump (exp, if_fals
*** 3342,3346 ****
  	      /* If the test is expected to fail, reverse the
  		 probabilities.  */
! 	      if (TREE_INT_CST_LOW (arg1) == 0)
  		taken = 1 - taken;
  
--- 3350,3354 ----
  	      /* If the test is expected to fail, reverse the
  		 probabilities.  */
! 	      if (integer_zerop (arg1))
  		taken = 1 - taken;
  
*** predict.c	2001/08/25 21:08:27	1.39
--- predict.c	2001/09/10 10:39:33
*************** expensive_function_p (threshold)
*** 794,798 ****
    unsigned int sum = 0;
    int i;
!   int limit;
  
    /* We can not compute accurately for large thresholds due to scaled
--- 794,798 ----
    unsigned int sum = 0;
    int i;
!   unsigned int limit;
  
    /* We can not compute accurately for large thresholds due to scaled
*** resource.c	2001/08/22 14:35:34	1.45
--- resource.c	2001/09/10 10:39:43
*************** mark_target_live_regs (insns, target, re
*** 892,896 ****
  {
    int b = -1;
!   int i;
    struct target_info *tinfo = NULL;
    rtx insn;
--- 892,896 ----
  {
    int b = -1;
!   unsigned int i;
    struct target_info *tinfo = NULL;
    rtx insn;
*************** mark_target_live_regs (insns, target, re
*** 950,954 ****
  	  tinfo->uid = INSN_UID (target);
  	  tinfo->block = b;
! 	  tinfo->next = target_hash_table[INSN_UID (target) % TARGET_HASH_PRIME];
  	  target_hash_table[INSN_UID (target) % TARGET_HASH_PRIME] = tinfo;
  	}
--- 950,955 ----
  	  tinfo->uid = INSN_UID (target);
  	  tinfo->block = b;
! 	  tinfo->next
! 	    = target_hash_table[INSN_UID (target) % TARGET_HASH_PRIME];
  	  target_hash_table[INSN_UID (target) % TARGET_HASH_PRIME] = tinfo;
  	}
*************** mark_target_live_regs (insns, target, re
*** 1062,1067 ****
  		    && REGNO (XEXP (link, 0)) < FIRST_PSEUDO_REGISTER)
  		  {
! 		    int first_regno = REGNO (XEXP (link, 0));
! 		    int last_regno
  		      = (first_regno
  			 + HARD_REGNO_NREGS (first_regno,
--- 1063,1068 ----
  		    && REGNO (XEXP (link, 0)) < FIRST_PSEUDO_REGISTER)
  		  {
! 		    unsigned int first_regno = REGNO (XEXP (link, 0));
! 		    unsigned int last_regno
  		      = (first_regno
  			 + HARD_REGNO_NREGS (first_regno,
*************** mark_target_live_regs (insns, target, re
*** 1081,1086 ****
  		    && REGNO (XEXP (link, 0)) < FIRST_PSEUDO_REGISTER)
  		  {
! 		    int first_regno = REGNO (XEXP (link, 0));
! 		    int last_regno
  		      = (first_regno
  			 + HARD_REGNO_NREGS (first_regno,
--- 1082,1087 ----
  		    && REGNO (XEXP (link, 0)) < FIRST_PSEUDO_REGISTER)
  		  {
! 		    unsigned int first_regno = REGNO (XEXP (link, 0));
! 		    unsigned int last_regno
  		      = (first_regno
  			 + HARD_REGNO_NREGS (first_regno,
*** sdbout.c	2001/08/22 14:35:41	1.55
--- sdbout.c	2001/09/10 10:39:51
*************** extern tree current_function_decl;
*** 95,102 ****
  static void sdbout_init			PARAMS ((const char *));
  static void sdbout_finish		PARAMS ((const char *));
! static void sdbout_start_source_file	PARAMS ((unsigned, const char *));
! static void sdbout_end_source_file	PARAMS ((unsigned));
! static void sdbout_begin_block		PARAMS ((unsigned, unsigned));
! static void sdbout_end_block		PARAMS ((unsigned, unsigned));
  static void sdbout_source_line		PARAMS ((unsigned int, const char *));
  static void sdbout_end_epilogue		PARAMS ((void));
--- 95,102 ----
  static void sdbout_init			PARAMS ((const char *));
  static void sdbout_finish		PARAMS ((const char *));
! static void sdbout_start_source_file	PARAMS ((unsigned int, const char *));
! static void sdbout_end_source_file	PARAMS ((unsigned int));
! static void sdbout_begin_block		PARAMS ((unsigned int, unsigned int));
! static void sdbout_end_block		PARAMS ((unsigned int, unsigned int));
  static void sdbout_source_line		PARAMS ((unsigned int, const char *));
  static void sdbout_end_epilogue		PARAMS ((void));
*************** do { fprintf (asm_out_file, "\t.tag\t");
*** 264,268 ****
  /* Ensure we don't output a negative line number.  */
  #define MAKE_LINE_SAFE(line)  \
!   if (line <= sdb_begin_function_line) line = sdb_begin_function_line + 1
  
  /* Perform linker optimization of merging header file definitions together
--- 264,269 ----
  /* Ensure we don't output a negative line number.  */
  #define MAKE_LINE_SAFE(line)  \
!   if ((int) line <= sdb_begin_function_line) \
!     line = sdb_begin_function_line + 1
  
  /* Perform linker optimization of merging header file definitions together
*************** sdbout_record_type_name (type)
*** 440,444 ****
       tree type;
  {
!   const char *name = 0;
    int no_name;
  
--- 441,445 ----
       tree type;
  {
!   char *name = 0;
    int no_name;
  
*************** sdbout_source_line (line, filename)
*** 1607,1611 ****
  {
    /* COFF relative line numbers must be positive.  */
!   if (line > sdb_begin_function_line)
      {
  #ifdef ASM_OUTPUT_SOURCE_LINE
--- 1608,1612 ----
  {
    /* COFF relative line numbers must be positive.  */
!   if ((int) line > sdb_begin_function_line)
      {
  #ifdef ASM_OUTPUT_SOURCE_LINE
*** config/alpha/alpha.c	2001/09/09 08:42:40	1.189
--- config/alpha/alpha.c	2001/09/10 10:40:18
*************** alpha_expand_block_move (operands)
*** 3600,3604 ****
  	    {
  	      data_regs[nregs] = gen_lowpart (DImode, tmp);
! 	      data_regs[nregs+1] = gen_highpart (DImode, tmp);
  	      nregs += 2;
  	    }
--- 3600,3604 ----
  	    {
  	      data_regs[nregs] = gen_lowpart (DImode, tmp);
! 	      data_regs[nregs + 1] = gen_highpart (DImode, tmp);
  	      nregs += 2;
  	    }
*************** alpha_expand_block_move (operands)
*** 3621,3625 ****
  
        for (i = 0; i < words; ++i)
! 	data_regs[nregs + i] = gen_reg_rtx(DImode);
  
        for (i = 0; i < words; ++i)
--- 3621,3625 ----
  
        for (i = 0; i < words; ++i)
! 	data_regs[nregs + i] = gen_reg_rtx (DImode);
  
        for (i = 0; i < words; ++i)
*************** alpha_expand_block_move (operands)
*** 3637,3641 ****
  
        for (i = 0; i < words; ++i)
! 	data_regs[nregs + i] = gen_reg_rtx(SImode);
  
        for (i = 0; i < words; ++i)
--- 3637,3641 ----
  
        for (i = 0; i < words; ++i)
! 	data_regs[nregs + i] = gen_reg_rtx (SImode);
  
        for (i = 0; i < words; ++i)
*************** alpha_expand_block_move (operands)
*** 3653,3657 ****
  
        for (i = 0; i < words+1; ++i)
! 	data_regs[nregs + i] = gen_reg_rtx(DImode);
  
        alpha_expand_unaligned_load_words (data_regs + nregs, orig_src,
--- 3653,3657 ----
  
        for (i = 0; i < words+1; ++i)
! 	data_regs[nregs + i] = gen_reg_rtx (DImode);
  
        alpha_expand_unaligned_load_words (data_regs + nregs, orig_src,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]