OSDN Git Service

* gcc.dg/20020201-1.c: Use cleanup-coverage_files.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / compare1.c
1 /* Test for a bogus warning on comparison between signed and unsigned.
2    This was inspired by code in gcc. */
3
4 /* { dg-do compile } */
5 /* { dg-options "-Wsign-compare" } */
6
7 int tf = 1;
8
9 /* This enumeration has an explicit negative value and is therefore signed.  */
10 enum mm1 
11 {
12   VOID, SI, DI, MAX = -1
13 };
14
15 /* This enumeration fits entirely in a signed int, but is unsigned anyway.  */
16 enum mm2
17 {
18   VOID2, SI2, DI2, MAX2
19 };
20
21 int f(enum mm1 x)
22 {
23   return x == (tf?DI:SI); /* { dg-bogus "signed and unsigned" "case 1" } */
24 }
25
26 int g(enum mm1 x)
27 {
28   return x == (tf?DI:-1); /* { dg-bogus "signed and unsigned" "case 2" } */
29 }
30
31 int h(enum mm2 x)
32 {
33   return x == (tf?DI2:SI2); /* { dg-bogus "signed and unsigned" "case 3" } */
34 }
35
36 int i(enum mm2 x)
37 {
38   return x == (tf?DI2:-1); /* { dg-warning "signed and unsigned" "case 4" } */
39 }