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" } */
9 void f(int x
, unsigned int y
)
11 /* ?: branches are constants. */
12 x
> (tf
?64:128); /* { dg-bogus "changes signedness" "case 1" } */
13 y
> (tf
?64:128); /* { dg-bogus "changes signedness" "case 2" } */
15 /* ?: branches are (recursively) constants. */
16 x
> (tf
?64:(tf
?128:256)); /* { dg-bogus "changes signedness" "case 3" } */
17 y
> (tf
?64:(tf
?128:256)); /* { dg-bogus "changes signedness" "case 4" } */
19 /* ?: branches are signed constants. */
20 x
> (tf
?64:-1); /* { dg-bogus "changes signedness" "case 5" } */
21 y
> (tf
?64:-1); /* { dg-warning "different signedness" "case 6" } */
23 /* ?: branches are (recursively) signed constants. */
24 x
> (tf
?64:(tf
?128:-1)); /* { dg-bogus "changes signedness" "case 7" } */
25 y
> (tf
?64:(tf
?128:-1)); /* { dg-warning "different signedness" "case 8" } */
27 /* Statement expression. */
28 x
> ({tf
; 64;}); /* { dg-bogus "changes signedness" "case 9" } */
29 y
> ({tf
; 64;}); /* { dg-bogus "changes signedness" "case 10" } */
31 /* Statement expression with recursive ?: . */
32 x
> ({tf
; tf
?64:(tf
?128:256);}); /* { dg-bogus "changes signedness" "case 11" } */
33 y
> ({tf
; tf
?64:(tf
?128:256);}); /* { dg-bogus "changes signedness" "case 12" } */
35 /* Statement expression with signed ?:. */
36 x
> ({tf
; tf
?64:-1;}); /* { dg-bogus "changes signedness" "case 13" } */
37 y
> ({tf
; tf
?64:-1;}); /* { dg-warning "different signedness" "case 14" } */
39 /* Statement expression with recursive signed ?:. */
40 x
> ({tf
; tf
?64:(tf
?128:-1);}); /* { dg-bogus "changes signedness" "case 15" } */
41 y
> ({tf
; tf
?64:(tf
?128:-1);}); /* { dg-warning "different signedness" "case 16" } */
43 /* ?: branches are constants. */
44 tf
? x
: (tf
?64:32); /* { dg-bogus "changes signedness" "case 17" } */
45 tf
? y
: (tf
?64:32); /* { dg-bogus "changes signedness" "case 18" } */
47 /* ?: branches are signed constants. */
48 tf
? x
: (tf
?64:-1); /* { dg-bogus "changes signedness" "case 19" } */
49 tf
? y
: (tf
?64:-1); /* { dg-warning "changes signedness" "case 20" } */
51 /* ?: branches are (recursively) constants. */
52 tf
? x
: (tf
?64:(tf
?128:256)); /* { dg-bogus "changes signedness" "case 21" } */
53 tf
? y
: (tf
?64:(tf
?128:256)); /* { dg-bogus "changes signedness" "case 22" } */
55 /* ?: branches are (recursively) signed constants. */
56 tf
? x
: (tf
?64:(tf
?128:-1)); /* { dg-bogus "changes signedness" "case 23" } */
57 tf
? y
: (tf
?64:(tf
?128:-1)); /* { dg-warning "changes signedness" "case 24" } */