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]

Re: [Commited] Constant fold (x | 5) != 0


On Tue, 23 Mar 2004, Joseph S. Myers wrote:
> It should be possible to write testcases for these, using the tree-level
> warnings that depend on whether something is known to be nonnegative.

An excellent suggestion!  I've just added the following testcase to
mainline, after testing with "make check-gcc" on i686-pc-linux-gnu.


2004-03-23  Joseph S. Myers  <jsm@polyomino.org.uk>
	    Roger Sayle  <roger@eyesopen.com>

	* gcc.dg/compare8.c: New test case.


/* { dg-do compile } */
/* { dg-options "-Wsign-compare" } */

int
f(unsigned short a1, unsigned short a2, unsigned int b)
{
  return ((a1+a2)|5) > b ? 2 : 3;  /* { dg-bogus "signed and unsigned" } */
}

int
g(unsigned short a1, unsigned short a2, unsigned int b)
{
  return ((a1+a2)&5) > b ? 2 : 3;  /* { dg-bogus "signed and unsigned" } */
}

Roger
--


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