2 /* { dg-do compile } */
3 /* { dg-options "-Wconversion -Wsign-conversion" } */
16 /* The result of boolean operators fits in unsiged int:1, thus do
18 unsigned_bit
.x
= (bar
!= 0); /* { dg-bogus "conversion" } */
19 unsigned_bit
.x
= (bar
== 0); /* { dg-bogus "conversion" } */
20 unsigned_bit
.x
= (bar
<= 0); /* { dg-bogus "conversion" } */
21 unsigned_bit
.x
= (bar
>= 0); /* { dg-bogus "conversion" } */
22 unsigned_bit
.x
= (bar
< 0); /* { dg-bogus "conversion" } */
23 unsigned_bit
.x
= (bar
> 0); /* { dg-bogus "conversion" } */
24 unsigned_bit
.x
= !bar
; /* { dg-bogus "conversion" } */
25 unsigned_bit
.x
= (bar
|| bar2
); /* { dg-bogus "conversion" } */
26 unsigned_bit
.x
= (bar
&& bar2
); /* { dg-bogus "conversion" } */
28 /* Both branches of ? fit in the destination, thus do not warn. */
29 unsigned_bit
.x
= bar
!= 0 ? 1 : 0; /* { dg-bogus "conversion" } */
30 unsigned_bit
.x
= bar
!= 0 ? 1.0 : 0.0; /* { dg-bogus "conversion" } */
32 /* At least one branch of ? does not fit in the destination, thus
34 unsigned_bit
.x
= bar
!= 0 ? 2 : 0; /* { dg-warning "conversion" } */
35 unsigned_bit
.x
= bar
!= 0 ? 0 : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
42 /* Both branches of ? fit in the destination, thus do not warn. */
43 schar_x
= bar
!= 0 ? 1 : 0; /* { dg-bogus "conversion" } */
44 schar_x
= bar
!= 0 ? 2.0 : 10; /* { dg-bogus "conversion" } */
46 /* At least one branch of ? does not fit in the destination, thus
48 schar_x
= bar
!= 0 ? 2.1 : 10; /* { dg-warning "conversion" } */
49 schar_x
= bar
!= 0 ? (signed char) 1024: -1024; /* { dg-warning "conversion" } */
56 unsigned char uchar_x
;
58 /* Both branches of ? fit in the destination, thus do not warn. */
59 uchar_x
= bar
!= 0 ? 1 : 0;
60 uchar_x
= bar
!= 0 ? 2.0 : 10;
62 /* At least one branch of ? does not fit in the destination, thus
64 uchar_x
= bar
!= 0 ? 2.1 : 10; /* { dg-warning "conversion" } */
66 ? (unsigned char) 1024
67 : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
72 signed_bit
.x
= -1; /* { dg-bogus "conversion" } */
73 signed_bit
.x
= bar
!= 0 ? -1.0 : 0.0; /* { dg-bogus "conversion" } */
74 signed_bit
.x
= bar
!= 0 ? -1 : 0; /* { dg-bogus "conversion" } */
77 signed_bit
.x
= 1; /* { dg-warning "conversion" } */
78 signed_bit
.x
= (bar
!= 0); /* { dg-warning "conversion" } */
79 signed_bit
.x
= (bar
== 0); /* { dg-warning "conversion" } */
80 signed_bit
.x
= (bar
<= 0); /* { dg-warning "conversion" } */
81 signed_bit
.x
= (bar
>= 0); /* { dg-warning "conversion" } */
82 signed_bit
.x
= (bar
< 0); /* { dg-warning "conversion" } */
83 signed_bit
.x
= (bar
> 0); /* { dg-warning "conversion" } */
84 signed_bit
.x
= !bar
; /* { dg-warning "conversion" } */
85 signed_bit
.x
= (bar
|| bar2
); /* { dg-warning "conversion" } */
86 signed_bit
.x
= (bar
&& bar2
); /* { dg-warning "conversion" } */
87 signed_bit
.x
= bar
!= 0 ? 1 : 0; /* { dg-warning "conversion" } */
88 signed_bit
.x
= bar
!= 0 ? 2 : 0; /* { dg-warning "conversion" } */