]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/lint-exceeding-bitshifts.rs
Imported Upstream version 1.3.0+dfsg1
[rustc.git] / src / test / compile-fail / lint-exceeding-bitshifts.rs
CommitLineData
1a4d82fc
JJ
1// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11#![deny(exceeding_bitshifts)]
12#![allow(unused_variables)]
13#![allow(dead_code)]
c1a9b12d 14#![feature(num_bits_bytes)]
1a4d82fc
JJ
15
16fn main() {
17 let n = 1u8 << 7;
18 let n = 1u8 << 8; //~ ERROR: bitshift exceeds the type's number of bits
19 let n = 1u16 << 15;
20 let n = 1u16 << 16; //~ ERROR: bitshift exceeds the type's number of bits
21 let n = 1u32 << 31;
22 let n = 1u32 << 32; //~ ERROR: bitshift exceeds the type's number of bits
23 let n = 1u64 << 63;
24 let n = 1u64 << 64; //~ ERROR: bitshift exceeds the type's number of bits
25 let n = 1i8 << 7;
26 let n = 1i8 << 8; //~ ERROR: bitshift exceeds the type's number of bits
27 let n = 1i16 << 15;
28 let n = 1i16 << 16; //~ ERROR: bitshift exceeds the type's number of bits
29 let n = 1i32 << 31;
30 let n = 1i32 << 32; //~ ERROR: bitshift exceeds the type's number of bits
31 let n = 1i64 << 63;
32 let n = 1i64 << 64; //~ ERROR: bitshift exceeds the type's number of bits
33
34 let n = 1u8 >> 7;
35 let n = 1u8 >> 8; //~ ERROR: bitshift exceeds the type's number of bits
36 let n = 1u16 >> 15;
37 let n = 1u16 >> 16; //~ ERROR: bitshift exceeds the type's number of bits
38 let n = 1u32 >> 31;
39 let n = 1u32 >> 32; //~ ERROR: bitshift exceeds the type's number of bits
40 let n = 1u64 >> 63;
41 let n = 1u64 >> 64; //~ ERROR: bitshift exceeds the type's number of bits
42 let n = 1i8 >> 7;
43 let n = 1i8 >> 8; //~ ERROR: bitshift exceeds the type's number of bits
44 let n = 1i16 >> 15;
45 let n = 1i16 >> 16; //~ ERROR: bitshift exceeds the type's number of bits
46 let n = 1i32 >> 31;
47 let n = 1i32 >> 32; //~ ERROR: bitshift exceeds the type's number of bits
48 let n = 1i64 >> 63;
49 let n = 1i64 >> 64; //~ ERROR: bitshift exceeds the type's number of bits
50
51 let n = 1u8;
52 let n = n << 7;
53 let n = n << 8; //~ ERROR: bitshift exceeds the type's number of bits
54
55 let n = 1u8 << -8; //~ ERROR: bitshift exceeds the type's number of bits
56
57 let n = 1u8 << (4+3);
58 let n = 1u8 << (4+4); //~ ERROR: bitshift exceeds the type's number of bits
59
85aaf69f
SL
60 let n = 1_isize << std::isize::BITS; //~ ERROR: bitshift exceeds the type's number of bits
61 let n = 1_usize << std::usize::BITS; //~ ERROR: bitshift exceeds the type's number of bits
c1a9b12d
SL
62
63
64 let n = 1i8<<(1isize+-1);
1a4d82fc 65}