1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify -Wtautological-compare %s
2*0a6a1f1dSLionel Sambuc
3*0a6a1f1dSLionel Sambuc #define mydefine 2
4*0a6a1f1dSLionel Sambuc
f(int x)5*0a6a1f1dSLionel Sambuc void f(int x) {
6*0a6a1f1dSLionel Sambuc if ((8 & x) == 3) {} // expected-warning {{bitwise comparison always evaluates to false}}
7*0a6a1f1dSLionel Sambuc if ((x & 8) == 4) {} // expected-warning {{bitwise comparison always evaluates to false}}
8*0a6a1f1dSLionel Sambuc if ((x & 8) != 4) {} // expected-warning {{bitwise comparison always evaluates to true}}
9*0a6a1f1dSLionel Sambuc if ((2 & x) != 4) {} // expected-warning {{bitwise comparison always evaluates to true}}
10*0a6a1f1dSLionel Sambuc if ((x | 4) == 3) {} // expected-warning {{bitwise comparison always evaluates to false}}
11*0a6a1f1dSLionel Sambuc if ((x | 3) != 4) {} // expected-warning {{bitwise comparison always evaluates to true}}
12*0a6a1f1dSLionel Sambuc if ((5 | x) != 3) {} // expected-warning {{bitwise comparison always evaluates to true}}
13*0a6a1f1dSLionel Sambuc if ((x & 0x15) == 0x13) {} // expected-warning {{bitwise comparison always evaluates to false}}
14*0a6a1f1dSLionel Sambuc if ((0x23 | x) == 0x155){} // expected-warning {{bitwise comparison always evaluates to false}}
15*0a6a1f1dSLionel Sambuc
16*0a6a1f1dSLionel Sambuc if ((x & 8) == 8) {}
17*0a6a1f1dSLionel Sambuc if ((x & 8) != 8) {}
18*0a6a1f1dSLionel Sambuc if ((x | 4) == 4) {}
19*0a6a1f1dSLionel Sambuc if ((x | 4) != 4) {}
20*0a6a1f1dSLionel Sambuc
21*0a6a1f1dSLionel Sambuc if ((x & 9) == 8) {}
22*0a6a1f1dSLionel Sambuc if ((x & 9) != 8) {}
23*0a6a1f1dSLionel Sambuc if ((x | 4) == 5) {}
24*0a6a1f1dSLionel Sambuc if ((x | 4) != 5) {}
25*0a6a1f1dSLionel Sambuc
26*0a6a1f1dSLionel Sambuc if ((x & mydefine) == 8) {}
27*0a6a1f1dSLionel Sambuc if ((x | mydefine) == 4) {}
28*0a6a1f1dSLionel Sambuc }
29