Move the c-torture/noncompile tests to either gcc.dg/cpp or a new
[official-gcc.git] / gcc / testsuite / gcc.dg / compare1.c
blob44c4df840ae0645a630991b6039c8f3c97c70a13
1 /* Test for a bogus warning on comparison between signed and unsigned.
2 This was inspired by code in gcc. */
4 /* { dg-do compile } */
5 /* { dg-options "-Wsign-compare" } */
7 int tf = 1;
9 /* This enumeration has an explicit negative value and is therefore signed. */
10 enum mm1
12 VOID, SI, DI, MAX = -1
15 /* This enumeration fits entirely in a signed int, but is unsigned anyway. */
16 enum mm2
18 VOID2, SI2, DI2, MAX2
21 int f(enum mm1 x)
23 return x == (tf?DI:SI); /* { dg-bogus "signed and unsigned" "case 1" } */
26 int g(enum mm1 x)
28 return x == (tf?DI:-1); /* { dg-bogus "signed and unsigned" "case 2" } */
31 int h(enum mm2 x)
33 return x == (tf?DI2:SI2); /* { dg-bogus "signed and unsigned" "case 3" } */
36 int i(enum mm2 x)
38 return x == (tf?DI2:-1); /* { dg-warning "signed and unsigned" "case 4" } */