brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.3 KiB · 11ed156 Raw
163 lines · c
1// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-logical-not-parentheses2 3 4void f(int x, int y, int z) {5  int a,b;6 7 8  if ((a > 2) > 1) {} // expected-warning {{comparison of constant 1 with boolean expression is always false}}9 10  if (a > b)      {} // no warning11  if (a < b)      {} // no warning12  if (a >= b)     {} // no warning13  if (a <= b)     {} // no warning14  if (a == b)     {} // no warning15  if (a != b)     {} // no warning16 17  if (a > 0) {} // no warning18  if (a > 1) {} // no warning19  if (a > 2) {} // no warning20 21  if (a >= 0) {} // no warning22  if (a >= 1) {} // no warning23  if (a >= 2) {} // no warning24  if (a >= -1) {} // no warning25 26  if (a <= 0) {} // no warning27  if (a <= 1) {} // no warning28  if (a <= 2) {} // no warning29  if (a <= -1) {} // no warning30 31 32  if (!a > 0) {}  // no warning33  if (!a > 1)     {} // expected-warning {{comparison of constant 1 with boolean expression is always false}}34  if (!a > 2)     {} // expected-warning {{comparison of constant 2 with boolean expression is always false}}35  if (!a > y)     {} // no warning36  if (!a > b)     {} // no warning37  if (!a > -1)    {} // expected-warning {{comparison of constant -1 with boolean expression is always true}}38 39  if (!a < 0)     {} // expected-warning {{comparison of constant 0 with boolean expression is always false}}40  if (!a < 1)     {} // no warning41  if (!a < 2)     {} // expected-warning {{comparison of constant 2 with boolean expression is always true}}42  if (!a < y)     {} // no warning43  if (!a < b)     {} // no warning44  if (!a < -1)    {} // expected-warning {{comparison of constant -1 with boolean expression is always false}}45 46  if (!a >= 0)    {} // expected-warning {{comparison of constant 0 with boolean expression is always true}}47  if (!a >= 1)    {} // no warning48  if (!a >= 2)    {} // expected-warning {{comparison of constant 2 with boolean expression is always false}}49  if (!a >= y)    {} // no warning50  if (!a >= b)    {} // no warning51  if (!a >= -1)   {} // expected-warning {{comparison of constant -1 with boolean expression is always true}}52 53  if (!a <= 0)    {} // no warning54  if (!a <= 1)    {} // expected-warning {{comparison of constant 1 with boolean expression is always true}}55  if (!a <= 2)    {} // expected-warning {{comparison of constant 2 with boolean expression is always true}}56  if (!a <= y)    {} // no warning57  if (!a <= b)    {} // no warning58  if (!a <= -1)   {} // expected-warning {{comparison of constant -1 with boolean expression is always false}}59 60  if ((a||b) > 0) {} // no warning61  if ((a||b) > 1) {} // expected-warning {{comparison of constant 1 with boolean expression is always false}}62  if ((a||b) > 4) {} // expected-warning {{comparison of constant 4 with boolean expression is always false}}63  if ((a||b) > -1) {}// expected-warning {{comparison of constant -1 with boolean expression is always true}}64 65  if ((a&&b) > 0) {} // no warning66  if ((a&&b) > 1) {} // expected-warning {{comparison of constant 1 with boolean expression is always false}}67  if ((a&&b) > 4) {} // expected-warning {{comparison of constant 4 with boolean expression is always false}}68 69  if ((a<y) > 0)  {} // no warning70  if ((a<y) > 1)  {} // expected-warning {{comparison of constant 1 with boolean expression is always false}}71  if ((a<y) > 4)  {} // expected-warning {{comparison of constant 4 with boolean expression is always false}}72  if ((a<y) > z)  {} // no warning73  if ((a<y) > -1) {} // expected-warning {{comparison of constant -1 with boolean expression is always true}}74 75  if ((a<y) == 0) {} // no warning76  if ((a<y) == 1) {} // no warning77  if ((a<y) == 2) {} // expected-warning {{comparison of constant 2 with boolean expression is always false}}78  if ((a<y) == z) {} // no warning79  if ((a<y) == -1) {}// expected-warning {{comparison of constant -1 with boolean expression is always false}}80 81  if ((a<y) != 0) {} // no warning82  if ((a<y) != 1) {} // no warning83  if ((a<y) != 2) {} // expected-warning {{comparison of constant 2 with boolean expression is always true}}84  if ((a<y) != z) {} // no warning85  if ((a<y) != -1) {}// expected-warning {{comparison of constant -1 with boolean expression is always true}}86 87  if ((a<y) == z) {} // no warning88  if (a>y<z)      {} // expected-error {{chained comparison 'X > Y < Z' does not behave the same as a mathematical expression}}89  if ((a<y) > z)  {} // no warning90  if((a<y)>(z<y)) {} // no warning91  if((a<y)==(z<y)){} // no warning92  if((a<y)!=(z<y)){} // no warning93  if((z==x)<(y==z)){}// no warning94  if((a<y)!=((z==x)<(y==z))){} //no warning95 96 97  if (0 > !a)     {} // expected-warning {{comparison of constant 0 with boolean expression is always false}}98  if (1 > !a)     {} // no warning99  if (2 > !a)     {} // expected-warning {{comparison of constant 2 with boolean expression is always true}}100  if (y > !a)     {} // no warning101  if (-1 > !a)    {} // expected-warning {{comparison of constant -1 with boolean expression is always false}}102 103  if (0 < !a)     {} // no warning104  if (1 < !a)     {} // expected-warning {{comparison of constant 1 with boolean expression is always false}}105  if (2 < !a)     {} // expected-warning {{comparison of constant 2 with boolean expression is always false}}106  if (y < !a)     {} // no warning107  if (-1 < !a)    {} // expected-warning {{comparison of constant -1 with boolean expression is always true}}108 109  if (0 >= !a)    {} // no warning110  if (1 >= !a)    {} // expected-warning {{comparison of constant 1 with boolean expression is always true}}111  if (2 >= !a)    {} // expected-warning {{comparison of constant 2 with boolean expression is always true}}112  if (y >= !a)    {} // no warning113  if (-1 >= !a)   {} // expected-warning {{comparison of constant -1 with boolean expression is always false}}114 115  if (0 <= !a)    {} // expected-warning {{comparison of constant 0 with boolean expression is always true}}116  if (1 <= !a)    {} // no warning117  if (2 <= !a)    {} // expected-warning {{comparison of constant 2 with boolean expression is always false}}118  if (y <= !a)    {} // no warning119  if (-1 <= !a)   {} // expected-warning {{comparison of constant -1 with boolean expression is always true}}120 121  if (0 > (a||b)) {} // expected-warning {{comparison of constant 0 with boolean expression is always false}}122  if (1 > (a||b)) {} // no warning123  if (4 > (a||b)) {} // expected-warning {{comparison of constant 4 with boolean expression is always true}}124 125  if (0 > (a&&b)) {} // expected-warning {{comparison of constant 0 with boolean expression is always false}}126  if (1 > (a&&b)) {} // no warning127  if (4 > (a&&b)) {} // expected-warning {{comparison of constant 4 with boolean expression is always true}}128 129  if (0 > (a<y))  {} // expected-warning {{comparison of constant 0 with boolean expression is always false}}130  if (1 > (a<y))  {} // no warning131  if (4 > (a<y))  {} // expected-warning {{comparison of constant 4 with boolean expression is always true}}132  if (z > (a<y))  {} // no warning133  if (-1 > (a<y)) {} // expected-warning {{comparison of constant -1 with boolean expression is always false}}134 135  if (0 == (a<y)) {} // no warning136  if (1 == (a<y)) {} // no warning137  if (2 == (a<y)) {} // expected-warning {{comparison of constant 2 with boolean expression is always false}}138  if (z == (a<y)) {} // no warning139  if (-1 == (a<y)){} // expected-warning {{comparison of constant -1 with boolean expression is always false}}140 141  if (0 !=(a<y))  {} // no warning142  if (1 !=(a<y))  {} // no warning143  if (2 !=(a<y))  {} // expected-warning {{comparison of constant 2 with boolean expression is always true}}144  if (z !=(a<y))  {} // no warning145  if (-1 !=(a<y)) {} // expected-warning {{comparison of constant -1 with boolean expression is always true}}146 147  if (z ==(a<y))  {}    // no warning148  if (z<a>y)      {} // expected-error {{chained comparison 'X < Y > Z' does not behave the same as a mathematical expression}}149  if (z > (a<y))  {}    // no warning150  if((z<y)>(a<y)) {}   // no warning151  if((z<y)==(a<y)){}  // no warning152  if((z<y)!=(a<y)){}  // no warning153  if((y==z)<(z==x)){}  // no warning154  if(((z==x)<(y==z))!=(a<y)){}  // no warning155 156  if(((z==x)<(-1==z))!=(a<y)){} // no warning157  if(((z==x)<(z==-1))!=(a<y)){} // no warning158  if(((z==x)<-1)!=(a<y)){} // expected-warning {{comparison of constant -1 with boolean expression is always false}}159  if(((z==x)< 2)!=(a<y)){} // expected-warning {{comparison of constant 2 with boolean expression is always true}}160  if(((z==x)<(z>2))!=(a<y)){} // no warning161 162}163