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]
Other format: [Raw text]

[PATCH] Fix compilation warnings in alpha.c


The following patch fixes four signed/unsigned comparison warnings
in alpha.c.  I believe frame_size should always be positive, and
on 32-bit hosts treating (1 << 31) as signed and therefore negative
is clearly wrong, so casting to (unsigned HOST_WIDE_INT) is the
correct fix.

Probably "obvious" but I'd prefer a second opinion.

Configured and bootstrapped with --enable-languages=c,c++,objc,f77
on alphaev67-dec-osf5.1, and regression tested with a top-level
"make -k check" with no new regressions.

Ok for mainline?


2003-05-08  Roger Sayle  <roger@eyesopen.com>

	* alpha.c (alpha_start_function): Cast frame_size to an unsigned
	HOST_WIDE_INT in comparisons to avoid compiler warnings.


Index: alpha.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/alpha/alpha.c,v
retrieving revision 1.302
diff -c -3 -p -r1.302 alpha.c
*** alpha.c	2 May 2003 01:05:43 -0000	1.302
--- alpha.c	8 May 2003 00:42:32 -0000
*************** alpha_start_function (file, fnname, decl
*** 7690,7696 ****
      {
        fprintf (file, "\t.frame $%d,", vms_unwind_regno);
        fprintf (file, HOST_WIDE_INT_PRINT_DEC,
! 	       frame_size >= (1UL << 31) ? 0 : frame_size);
        fputs (",$26,", file);
        fprintf (file, HOST_WIDE_INT_PRINT_DEC, reg_offset);
        fputs ("\n", file);
--- 7690,7697 ----
      {
        fprintf (file, "\t.frame $%d,", vms_unwind_regno);
        fprintf (file, HOST_WIDE_INT_PRINT_DEC,
! 	       (unsigned HOST_WIDE_INT) frame_size >= (1UL << 31)
! 	       ? 0 : frame_size);
        fputs (",$26,", file);
        fprintf (file, HOST_WIDE_INT_PRINT_DEC, reg_offset);
        fputs ("\n", file);
*************** alpha_start_function (file, fnname, decl
*** 7701,7707 ****
  	       (frame_pointer_needed
  		? HARD_FRAME_POINTER_REGNUM : STACK_POINTER_REGNUM));
        fprintf (file, HOST_WIDE_INT_PRINT_DEC,
! 	       frame_size >= (1UL << 31) ? 0 : frame_size);
        fprintf (file, ",$26,%d\n", current_function_pretend_args_size);
      }

--- 7702,7709 ----
  	       (frame_pointer_needed
  		? HARD_FRAME_POINTER_REGNUM : STACK_POINTER_REGNUM));
        fprintf (file, HOST_WIDE_INT_PRINT_DEC,
! 	       (unsigned HOST_WIDE_INT) frame_size >= (1UL << 31)
! 	       ? 0 : frame_size);
        fprintf (file, ",$26,%d\n", current_function_pretend_args_size);
      }

*************** alpha_start_function (file, fnname, decl
*** 7725,7731 ****
  	{
  	  fprintf (file, "\t.mask 0x%lx,", imask);
  	  fprintf (file, HOST_WIDE_INT_PRINT_DEC,
! 		   frame_size >= (1UL << 31) ? 0 : reg_offset - frame_size);
  	  putc ('\n', file);

  	  for (i = 0; i < 32; ++i)
--- 7727,7734 ----
  	{
  	  fprintf (file, "\t.mask 0x%lx,", imask);
  	  fprintf (file, HOST_WIDE_INT_PRINT_DEC,
! 		   (unsigned HOST_WIDE_INT) frame_size >= (1UL << 31)
! 		   ? 0 : reg_offset - frame_size);
  	  putc ('\n', file);

  	  for (i = 0; i < 32; ++i)
*************** alpha_start_function (file, fnname, decl
*** 7737,7743 ****
  	{
  	  fprintf (file, "\t.fmask 0x%lx,", fmask);
  	  fprintf (file, HOST_WIDE_INT_PRINT_DEC,
! 		   frame_size >= (1UL << 31) ? 0 : reg_offset - frame_size);
  	  putc ('\n', file);
  	}
      }
--- 7740,7747 ----
  	{
  	  fprintf (file, "\t.fmask 0x%lx,", fmask);
  	  fprintf (file, HOST_WIDE_INT_PRINT_DEC,
! 		   (unsigned HOST_WIDE_INT) frame_size >= (1UL << 31)
! 		   ? 0 : reg_offset - frame_size);
  	  putc ('\n', file);
  	}
      }


Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833


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