1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-logical-not-parentheses 2*67e74705SXin Li 3*67e74705SXin Li f(int x,int y,int z)4*67e74705SXin Livoid f(int x, int y, int z) { 5*67e74705SXin Li int a,b; 6*67e74705SXin Li 7*67e74705SXin Li 8*67e74705SXin Li if ((a > 2) > 1) {} // expected-warning {{comparison of constant 1 with boolean expression is always false}} 9*67e74705SXin Li 10*67e74705SXin Li if (a > b) {} // no warning 11*67e74705SXin Li if (a < b) {} // no warning 12*67e74705SXin Li if (a >= b) {} // no warning 13*67e74705SXin Li if (a <= b) {} // no warning 14*67e74705SXin Li if (a == b) {} // no warning 15*67e74705SXin Li if (a != b) {} // no warning 16*67e74705SXin Li 17*67e74705SXin Li if (a > 0) {} // no warning 18*67e74705SXin Li if (a > 1) {} // no warning 19*67e74705SXin Li if (a > 2) {} // no warning 20*67e74705SXin Li 21*67e74705SXin Li if (a >= 0) {} // no warning 22*67e74705SXin Li if (a >= 1) {} // no warning 23*67e74705SXin Li if (a >= 2) {} // no warning 24*67e74705SXin Li if (a >= -1) {} // no warning 25*67e74705SXin Li 26*67e74705SXin Li if (a <= 0) {} // no warning 27*67e74705SXin Li if (a <= 1) {} // no warning 28*67e74705SXin Li if (a <= 2) {} // no warning 29*67e74705SXin Li if (a <= -1) {} // no warning 30*67e74705SXin Li 31*67e74705SXin Li 32*67e74705SXin Li if (!a > 0) {} // no warning 33*67e74705SXin Li if (!a > 1) {} // expected-warning {{comparison of constant 1 with boolean expression is always false}} 34*67e74705SXin Li if (!a > 2) {} // expected-warning {{comparison of constant 2 with boolean expression is always false}} 35*67e74705SXin Li if (!a > y) {} // no warning 36*67e74705SXin Li if (!a > b) {} // no warning 37*67e74705SXin Li if (!a > -1) {} // expected-warning {{comparison of constant -1 with boolean expression is always true}} 38*67e74705SXin Li 39*67e74705SXin Li if (!a < 0) {} // expected-warning {{comparison of constant 0 with boolean expression is always false}} 40*67e74705SXin Li if (!a < 1) {} // no warning 41*67e74705SXin Li if (!a < 2) {} // expected-warning {{comparison of constant 2 with boolean expression is always true}} 42*67e74705SXin Li if (!a < y) {} // no warning 43*67e74705SXin Li if (!a < b) {} // no warning 44*67e74705SXin Li if (!a < -1) {} // expected-warning {{comparison of constant -1 with boolean expression is always false}} 45*67e74705SXin Li 46*67e74705SXin Li if (!a >= 0) {} // expected-warning {{comparison of constant 0 with boolean expression is always true}} 47*67e74705SXin Li if (!a >= 1) {} // no warning 48*67e74705SXin Li if (!a >= 2) {} // expected-warning {{comparison of constant 2 with boolean expression is always false}} 49*67e74705SXin Li if (!a >= y) {} // no warning 50*67e74705SXin Li if (!a >= b) {} // no warning 51*67e74705SXin Li if (!a >= -1) {} // expected-warning {{comparison of constant -1 with boolean expression is always true}} 52*67e74705SXin Li 53*67e74705SXin Li if (!a <= 0) {} // no warning 54*67e74705SXin Li if (!a <= 1) {} // expected-warning {{comparison of constant 1 with boolean expression is always true}} 55*67e74705SXin Li if (!a <= 2) {} // expected-warning {{comparison of constant 2 with boolean expression is always true}} 56*67e74705SXin Li if (!a <= y) {} // no warning 57*67e74705SXin Li if (!a <= b) {} // no warning 58*67e74705SXin Li if (!a <= -1) {} // expected-warning {{comparison of constant -1 with boolean expression is always false}} 59*67e74705SXin Li 60*67e74705SXin Li if ((a||b) > 0) {} // no warning 61*67e74705SXin Li if ((a||b) > 1) {} // expected-warning {{comparison of constant 1 with boolean expression is always false}} 62*67e74705SXin Li if ((a||b) > 4) {} // expected-warning {{comparison of constant 4 with boolean expression is always false}} 63*67e74705SXin Li if ((a||b) > -1) {}// expected-warning {{comparison of constant -1 with boolean expression is always true}} 64*67e74705SXin Li 65*67e74705SXin Li if ((a&&b) > 0) {} // no warning 66*67e74705SXin Li if ((a&&b) > 1) {} // expected-warning {{comparison of constant 1 with boolean expression is always false}} 67*67e74705SXin Li if ((a&&b) > 4) {} // expected-warning {{comparison of constant 4 with boolean expression is always false}} 68*67e74705SXin Li 69*67e74705SXin Li if ((a<y) > 0) {} // no warning 70*67e74705SXin Li if ((a<y) > 1) {} // expected-warning {{comparison of constant 1 with boolean expression is always false}} 71*67e74705SXin Li if ((a<y) > 4) {} // expected-warning {{comparison of constant 4 with boolean expression is always false}} 72*67e74705SXin Li if ((a<y) > z) {} // no warning 73*67e74705SXin Li if ((a<y) > -1) {} // expected-warning {{comparison of constant -1 with boolean expression is always true}} 74*67e74705SXin Li 75*67e74705SXin Li if ((a<y) == 0) {} // no warning 76*67e74705SXin Li if ((a<y) == 1) {} // no warning 77*67e74705SXin Li if ((a<y) == 2) {} // expected-warning {{comparison of constant 2 with boolean expression is always false}} 78*67e74705SXin Li if ((a<y) == z) {} // no warning 79*67e74705SXin Li if ((a<y) == -1) {}// expected-warning {{comparison of constant -1 with boolean expression is always false}} 80*67e74705SXin Li 81*67e74705SXin Li if ((a<y) != 0) {} // no warning 82*67e74705SXin Li if ((a<y) != 1) {} // no warning 83*67e74705SXin Li if ((a<y) != 2) {} // expected-warning {{comparison of constant 2 with boolean expression is always true}} 84*67e74705SXin Li if ((a<y) != z) {} // no warning 85*67e74705SXin Li if ((a<y) != -1) {}// expected-warning {{comparison of constant -1 with boolean expression is always true}} 86*67e74705SXin Li 87*67e74705SXin Li if ((a<y) == z) {} // no warning 88*67e74705SXin Li if (a>y<z) {} // no warning 89*67e74705SXin Li if ((a<y) > z) {} // no warning 90*67e74705SXin Li if((a<y)>(z<y)) {} // no warning 91*67e74705SXin Li if((a<y)==(z<y)){} // no warning 92*67e74705SXin Li if((a<y)!=(z<y)){} // no warning 93*67e74705SXin Li if((z==x)<(y==z)){}// no warning 94*67e74705SXin Li if((a<y)!=((z==x)<(y==z))){} //no warning 95*67e74705SXin Li 96*67e74705SXin Li 97*67e74705SXin Li if (0 > !a) {} // expected-warning {{comparison of constant 0 with boolean expression is always false}} 98*67e74705SXin Li if (1 > !a) {} // no warning 99*67e74705SXin Li if (2 > !a) {} // expected-warning {{comparison of constant 2 with boolean expression is always true}} 100*67e74705SXin Li if (y > !a) {} // no warning 101*67e74705SXin Li if (-1 > !a) {} // expected-warning {{comparison of constant -1 with boolean expression is always false}} 102*67e74705SXin Li 103*67e74705SXin Li if (0 < !a) {} // no warning 104*67e74705SXin Li if (1 < !a) {} // expected-warning {{comparison of constant 1 with boolean expression is always false}} 105*67e74705SXin Li if (2 < !a) {} // expected-warning {{comparison of constant 2 with boolean expression is always false}} 106*67e74705SXin Li if (y < !a) {} // no warning 107*67e74705SXin Li if (-1 < !a) {} // expected-warning {{comparison of constant -1 with boolean expression is always true}} 108*67e74705SXin Li 109*67e74705SXin Li if (0 >= !a) {} // no warning 110*67e74705SXin Li if (1 >= !a) {} // expected-warning {{comparison of constant 1 with boolean expression is always true}} 111*67e74705SXin Li if (2 >= !a) {} // expected-warning {{comparison of constant 2 with boolean expression is always true}} 112*67e74705SXin Li if (y >= !a) {} // no warning 113*67e74705SXin Li if (-1 >= !a) {} // expected-warning {{comparison of constant -1 with boolean expression is always false}} 114*67e74705SXin Li 115*67e74705SXin Li if (0 <= !a) {} // expected-warning {{comparison of constant 0 with boolean expression is always true}} 116*67e74705SXin Li if (1 <= !a) {} // no warning 117*67e74705SXin Li if (2 <= !a) {} // expected-warning {{comparison of constant 2 with boolean expression is always false}} 118*67e74705SXin Li if (y <= !a) {} // no warning 119*67e74705SXin Li if (-1 <= !a) {} // expected-warning {{comparison of constant -1 with boolean expression is always true}} 120*67e74705SXin Li 121*67e74705SXin Li if (0 > (a||b)) {} // expected-warning {{comparison of constant 0 with boolean expression is always false}} 122*67e74705SXin Li if (1 > (a||b)) {} // no warning 123*67e74705SXin Li if (4 > (a||b)) {} // expected-warning {{comparison of constant 4 with boolean expression is always true}} 124*67e74705SXin Li 125*67e74705SXin Li if (0 > (a&&b)) {} // expected-warning {{comparison of constant 0 with boolean expression is always false}} 126*67e74705SXin Li if (1 > (a&&b)) {} // no warning 127*67e74705SXin Li if (4 > (a&&b)) {} // expected-warning {{comparison of constant 4 with boolean expression is always true}} 128*67e74705SXin Li 129*67e74705SXin Li if (0 > (a<y)) {} // expected-warning {{comparison of constant 0 with boolean expression is always false}} 130*67e74705SXin Li if (1 > (a<y)) {} // no warning 131*67e74705SXin Li if (4 > (a<y)) {} // expected-warning {{comparison of constant 4 with boolean expression is always true}} 132*67e74705SXin Li if (z > (a<y)) {} // no warning 133*67e74705SXin Li if (-1 > (a<y)) {} // expected-warning {{comparison of constant -1 with boolean expression is always false}} 134*67e74705SXin Li 135*67e74705SXin Li if (0 == (a<y)) {} // no warning 136*67e74705SXin Li if (1 == (a<y)) {} // no warning 137*67e74705SXin Li if (2 == (a<y)) {} // expected-warning {{comparison of constant 2 with boolean expression is always false}} 138*67e74705SXin Li if (z == (a<y)) {} // no warning 139*67e74705SXin Li if (-1 == (a<y)){} // expected-warning {{comparison of constant -1 with boolean expression is always false}} 140*67e74705SXin Li 141*67e74705SXin Li if (0 !=(a<y)) {} // no warning 142*67e74705SXin Li if (1 !=(a<y)) {} // no warning 143*67e74705SXin Li if (2 !=(a<y)) {} // expected-warning {{comparison of constant 2 with boolean expression is always true}} 144*67e74705SXin Li if (z !=(a<y)) {} // no warning 145*67e74705SXin Li if (-1 !=(a<y)) {} // expected-warning {{comparison of constant -1 with boolean expression is always true}} 146*67e74705SXin Li 147*67e74705SXin Li if (z ==(a<y)) {} // no warning 148*67e74705SXin Li if (z<a>y) {} // no warning 149*67e74705SXin Li if (z > (a<y)) {} // no warning 150*67e74705SXin Li if((z<y)>(a<y)) {} // no warning 151*67e74705SXin Li if((z<y)==(a<y)){} // no warning 152*67e74705SXin Li if((z<y)!=(a<y)){} // no warning 153*67e74705SXin Li if((y==z)<(z==x)){} // no warning 154*67e74705SXin Li if(((z==x)<(y==z))!=(a<y)){} // no warning 155*67e74705SXin Li 156*67e74705SXin Li if(((z==x)<(-1==z))!=(a<y)){} // no warning 157*67e74705SXin Li if(((z==x)<(z==-1))!=(a<y)){} // no warning 158*67e74705SXin Li if(((z==x)<-1)!=(a<y)){} // expected-warning {{comparison of constant -1 with boolean expression is always false}} 159*67e74705SXin Li if(((z==x)< 2)!=(a<y)){} // expected-warning {{comparison of constant 2 with boolean expression is always true}} 160*67e74705SXin Li if(((z==x)<(z>2))!=(a<y)){} // no warning 161*67e74705SXin Li 162*67e74705SXin Li } 163