]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lint/lint-exceeding-bitshifts.rs
121e5b796bbb714015cba9f426caac51b4602764
[rust.git] / src / test / ui / lint / lint-exceeding-bitshifts.rs
1 // build-fail
2 // compile-flags: -O
3
4 #![deny(exceeding_bitshifts, const_err)]
5 #![allow(unused_variables)]
6 #![allow(dead_code)]
7
8 fn main() {
9       let n = 1u8 << 7;
10       let n = 1u8 << 8;   //~ ERROR: attempt to shift left with overflow
11       let n = 1u16 << 15;
12       let n = 1u16 << 16; //~ ERROR: attempt to shift left with overflow
13       let n = 1u32 << 31;
14       let n = 1u32 << 32; //~ ERROR: attempt to shift left with overflow
15       let n = 1u64 << 63;
16       let n = 1u64 << 64; //~ ERROR: attempt to shift left with overflow
17       let n = 1i8 << 7;
18       let n = 1i8 << 8;   //~ ERROR: attempt to shift left with overflow
19       let n = 1i16 << 15;
20       let n = 1i16 << 16; //~ ERROR: attempt to shift left with overflow
21       let n = 1i32 << 31;
22       let n = 1i32 << 32; //~ ERROR: attempt to shift left with overflow
23       let n = 1i64 << 63;
24       let n = 1i64 << 64; //~ ERROR: attempt to shift left with overflow
25
26       let n = 1u8 >> 7;
27       let n = 1u8 >> 8;   //~ ERROR: attempt to shift right with overflow
28       let n = 1u16 >> 15;
29       let n = 1u16 >> 16; //~ ERROR: attempt to shift right with overflow
30       let n = 1u32 >> 31;
31       let n = 1u32 >> 32; //~ ERROR: attempt to shift right with overflow
32       let n = 1u64 >> 63;
33       let n = 1u64 >> 64; //~ ERROR: attempt to shift right with overflow
34       let n = 1i8 >> 7;
35       let n = 1i8 >> 8;   //~ ERROR: attempt to shift right with overflow
36       let n = 1i16 >> 15;
37       let n = 1i16 >> 16; //~ ERROR: attempt to shift right with overflow
38       let n = 1i32 >> 31;
39       let n = 1i32 >> 32; //~ ERROR: attempt to shift right with overflow
40       let n = 1i64 >> 63;
41       let n = 1i64 >> 64; //~ ERROR: attempt to shift right with overflow
42
43       let n = 1u8;
44       let n = n << 7;
45       let n = n << 8; //~ ERROR: attempt to shift left with overflow
46
47       let n = 1u8 << -8; //~ ERROR: attempt to shift left with overflow
48
49       let n = 1i8<<(1isize+-1);
50 }