PR c/64856
[official-gcc.git] / gcc / testsuite / gcc.dg / compare5.c
blobf19c575efb7927e20fa03a6010dfb4960e5cf70d
1 /* Test for a bogus warning on comparison between signed and unsigned.
2 Origin: Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 8/21/2001. */
4 /* { dg-do compile } */
5 /* { dg-options "-Wsign-compare" } */
7 extern void bar(void);
9 int foo(int x, int y, unsigned u)
11 /* A *_DIV_EXPR is non-negative if both operands are. */
13 if (u < ((x=-22)/33)) /* { dg-warning "signed and unsigned" "DIV_EXPR" } */
14 return x;
16 if (u < ((x=22)/33))
17 return x;
19 if (u < ((x=22)/(y=33)))
20 return x;
22 if (u < (((x&0x10000)?128:64) / ((y&0x10000)?8:4)))
23 return x;
26 /* A *_MOD_EXPR is non-negative if the first operand is. */
28 if (u < ((x=-22)%33)) /* { dg-warning "signed and unsigned" "MOD_EXPR" } */
29 return x;
31 if (u < ((x=22)%-33))
32 return x;
34 if (u < ((x==y)%-33))
35 return x;
37 if (u < (((x=22)/33)%-33))
38 return x;
40 return 0;