This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Commited] Constant fold (x | 5) != 0
- From: Roger Sayle <roger at eyesopen dot com>
- To: "Joseph S. Myers" <jsm at polyomino dot org dot uk>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 23 Mar 2004 16:05:37 -0700 (MST)
- Subject: 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
--