[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Analysis / bitwise-ops.c
blobd8d2c920517d4cc2c3971c563f345c294dd3f6ed
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -triple x86_64-apple-darwin13 -Wno-shift-count-overflow -verify %s
3 void clang_analyzer_eval(int);
4 #define CHECK(expr) if (!(expr)) return; clang_analyzer_eval(expr)
6 void testPersistentConstraints(int x, int y) {
7 // Basic check
8 CHECK(x); // expected-warning{{TRUE}}
9 CHECK(x & 1); // expected-warning{{TRUE}}
11 CHECK(1 - x); // expected-warning{{TRUE}}
12 CHECK(x & y); // expected-warning{{TRUE}}
15 int testConstantShifts_PR18073(int which) {
16 // FIXME: We should have a checker that actually specifically checks bitwise
17 // shifts against the width of the LHS's /static/ type, rather than just
18 // having BasicValueFactory return "undefined" when dealing with two constant
19 // operands.
20 switch (which) {
21 case 1:
22 return 0ULL << 63; // no-warning
23 case 2:
24 return 0ULL << 64; // expected-warning{{The result of the left shift is undefined due to shifting by '64', which is greater or equal to the width of type 'unsigned long long'}}
25 case 3:
26 return 0ULL << 65; // expected-warning{{The result of the left shift is undefined due to shifting by '65', which is greater or equal to the width of type 'unsigned long long'}}
28 default:
29 return 0;
33 int testOverflowShift(int a) {
34 if (a == 323) {
35 return 1 << a; // expected-warning{{The result of the left shift is undefined due to shifting by '323', which is greater or equal to the width of type 'int'}}
37 return 0;
40 int testNegativeShift(int a) {
41 if (a == -5) {
42 return 1 << a; // expected-warning{{The result of the left shift is undefined because the right operand is negative}}
44 return 0;
47 int testNegativeLeftShift(int a) {
48 if (a == -3) {
49 return a << 1; // expected-warning{{The result of the left shift is undefined because the left operand is negative}}
51 return 0;
54 int testUnrepresentableLeftShift(int a) {
55 if (a == 8)
56 return a << 30; // expected-warning{{The result of the left shift is undefined due to shifting '8' by '30', which is unrepresentable in the unsigned version of the return type 'int'}}
57 return 0;