1 // RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify -std=c99 -Dbool=_Bool -Dtrue=1 -Dfalse=0 %s 2 // RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify -std=c11 -Dbool=_Bool -Dtrue=1 -Dfalse=0 %s 3 extern void clang_analyzer_eval(bool); 4 test__Bool_value()5void test__Bool_value() { 6 { 7 bool b = true; 8 clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} 9 } 10 11 { 12 bool b = false; 13 clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} 14 } 15 16 { 17 bool b = -10; 18 clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} 19 } 20 21 { 22 bool b = 10; 23 clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} 24 } 25 26 { 27 bool b = 10; 28 b++; 29 clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} 30 } 31 32 { 33 bool b = 0; 34 b++; 35 clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} 36 } 37 } 38 test__Bool_increment()39void test__Bool_increment() { 40 { 41 bool b = true; 42 b++; 43 clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} 44 } 45 46 { 47 bool b = false; 48 b++; 49 clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} 50 } 51 52 { 53 bool b = true; 54 ++b; 55 clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} 56 } 57 58 { 59 bool b = false; 60 ++b; 61 clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} 62 } 63 64 { 65 bool b = 0; 66 ++b; 67 clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} 68 } 69 70 { 71 bool b = 10; 72 ++b; 73 ++b; 74 clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} 75 } 76 77 { 78 bool b = -10; 79 ++b; 80 clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} 81 } 82 83 { 84 bool b = -1; 85 ++b; 86 clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} 87 } 88 } 89 test__Bool_decrement()90void test__Bool_decrement() { 91 { 92 bool b = true; 93 b--; 94 clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} 95 } 96 97 { 98 bool b = false; 99 b--; 100 clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} 101 } 102 103 { 104 bool b = true; 105 --b; 106 clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} 107 } 108 109 { 110 bool b = false; 111 --b; 112 clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} 113 } 114 115 { 116 bool b = 0; 117 --b; 118 clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} 119 } 120 121 { 122 bool b = 10; 123 --b; 124 clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} 125 --b; 126 clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} 127 } 128 129 { 130 bool b = -10; 131 --b; 132 clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} 133 } 134 135 { 136 bool b = 1; 137 --b; 138 clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} 139 } 140 } 141