1 | // RUN: %check_clang_tidy %s hicpp-signed-bitwise %t -- \ |
2 | // RUN: -config="{CheckOptions: {hicpp-signed-bitwise.IgnorePositiveIntegerLiterals: true}}" \ |
3 | // RUN: -- -std=c++11 |
4 | |
5 | void examples() { |
6 | unsigned UValue = 40u; |
7 | unsigned URes; |
8 | |
9 | URes = UValue & 1u; //Ok |
10 | URes = UValue & -1; |
11 | // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use of a signed integer operand with a binary bitwise operator |
12 | |
13 | unsigned URes2 = URes << 1; //Ok |
14 | |
15 | int IResult; |
16 | IResult = 10 & 2; //Ok |
17 | IResult = 3 << -1; |
18 | // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: use of a signed integer operand with a binary bitwise operator |
19 | |
20 | int Int = 30; |
21 | IResult = Int << 1; |
22 | // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator |
23 | IResult = ~0; //Ok |
24 | } |
25 | |
26 | enum EnumConstruction { |
27 | one = 1, |
28 | two = 2, |
29 | test1 = 1 << 12, //Ok |
30 | test2 = one << two, |
31 | // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use of a signed integer operand with a binary bitwise operator |
32 | test3 = 1u << 12, //Ok |
33 | }; |
34 | |