1/* PR 34389 */ 2/* { dg-do compile } */ 3/* { dg-options "-Wconversion -Wsign-conversion" } */ 4/* { dg-require-effective-target int32plus } */ 5short mask1(short x) 6{ 7 short y = 0x7fff; 8 return x & y; /* { dg-bogus "conversion" "bogus warning" } */ 9} 10 11short mask2(short ssx) 12{ 13 short ssy; 14 short ssz; 15 16 ssz = ((int)ssx) & 0x7fff; 17 ssy = ((int)ssx) | 0x7fff; 18 ssz = ((int)ssx) ^ 0x7fff; 19 return ssx & 0x7fff; 20} 21 22short mask3(int si, unsigned int ui) 23{ 24 short ss; 25 unsigned short us; 26 27 ss = si & 0x7fff; 28 ss = si & 0xAAAA; /* { dg-warning "conversion" } */ 29 ss = ui & 0x7fff; 30 ss = ui & 0xAAAA; /* { dg-warning "conversion" } */ 31 32 us = si & 0x7fff; 33 us = si & 0xAAAA; /* { dg-warning "conversion" } */ 34 us = ui & 0x7fff; 35 us = ui & 0xAAAA; /* 0xAAAA is zero-extended, thus it masks the 36 upper bits of 'ui' making it fit in 'us'. */ 37 38 return ss; 39} 40 41short mask4(int x, int y) 42{ 43 return x & y; /* { dg-warning "conversion" } */ 44} 45 46short mask5(int x) 47{ 48 return x & -1; /* { dg-warning "conversion" } */ 49} 50 51short mask6(short x) 52{ 53 return x & -1; 54} 55