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