1 // RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify -std=c++98 -Wno-deprecated %s 2 // RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify -std=c++11 -Wno-deprecated %s 3 // RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify -std=c++14 -Wno-deprecated %s 4 5 extern void clang_analyzer_eval(bool); 6 test_bool_value()7void test_bool_value() { 8 { 9 bool b = true; 10 clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} 11 } 12 13 { 14 bool b = false; 15 clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} 16 } 17 18 { 19 bool b = -10; 20 clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} 21 } 22 23 { 24 bool b = 10; 25 clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} 26 } 27 28 { 29 bool b = 10; 30 b++; 31 clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} 32 } 33 34 { 35 bool b = 0; 36 b++; 37 clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} 38 } 39 } 40 test_bool_increment()41void test_bool_increment() { 42 { 43 bool b = true; 44 b++; 45 clang_analyzer_eval(b); // expected-warning{{TRUE}} 46 } 47 48 { 49 bool b = false; 50 b++; 51 clang_analyzer_eval(b); // expected-warning{{TRUE}} 52 } 53 54 { 55 bool b = true; 56 ++b; 57 clang_analyzer_eval(b); // expected-warning{{TRUE}} 58 } 59 60 { 61 bool b = false; 62 ++b; 63 clang_analyzer_eval(b); // expected-warning{{TRUE}} 64 } 65 66 { 67 bool b = 0; 68 ++b; 69 clang_analyzer_eval(b); // expected-warning{{TRUE}} 70 } 71 72 { 73 bool b = 10; 74 ++b; 75 ++b; 76 clang_analyzer_eval(b); // expected-warning{{TRUE}} 77 } 78 79 { 80 bool b = -10; 81 ++b; 82 clang_analyzer_eval(b); // expected-warning{{TRUE}} 83 } 84 } 85