PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / Wconversion-pr34389.c
blob1a4336802606e5c40e27a50e63a83cad2e9c0202
1 /* PR 34389 */
2 /* { dg-do compile } */
3 /* { dg-options "-Wconversion -Wsign-conversion" } */
4 /* { dg-require-effective-target int32plus } */
6 short mask1(short x)
8 short y = 0x7fff;
9 return x & y;
12 short mask2(short ssx)
14 short ssy;
15 short ssz;
17 ssz = ((int)ssx) & 0x7fff;
18 ssy = ((int)ssx) | 0x7fff;
19 ssz = ((int)ssx) ^ 0x7fff;
20 return ssx & 0x7fff;
23 short mask3(int si, unsigned int ui)
25 short ss;
26 unsigned short us;
28 ss = si & 0x7fff;
29 ss = si & 0xAAAA; /* { dg-warning "conversion" } */
30 ss = ui & 0x7fff;
31 ss = ui & 0xAAAA; /* { dg-warning "conversion" } */
33 us = si & 0x7fff;
34 us = si & 0xAAAA; /* { dg-warning "conversion" } */
35 us = ui & 0x7fff;
36 us = ui & 0xAAAA; /* 0xAAAA is zero-extended, thus it masks the
37 upper bits of 'ui' making it fit in 'us'. */
39 return ss;
42 short mask4(int x, int y)
44 return x & y; /* { dg-warning "conversion" } */
47 short mask5(int x)
49 return x & -1; /* { dg-warning "conversion" } */
52 short mask6(short x)
54 return x & -1;