blob: 175f8f5367f335ee4acca2c38cf06abe3060fe85 [file] [log] [blame]
Stephen Hines6bcf27b2014-05-29 04:14:42 -07001// RUN: %clang_cc1 -fsyntax-only -verify -Wtautological-compare %s
2
3#define mydefine 2
4
5void f(int x) {
6 if ((8 & x) == 3) {} // expected-warning {{bitwise comparison always evaluates to false}}
7 if ((x & 8) == 4) {} // expected-warning {{bitwise comparison always evaluates to false}}
8 if ((x & 8) != 4) {} // expected-warning {{bitwise comparison always evaluates to true}}
9 if ((2 & x) != 4) {} // expected-warning {{bitwise comparison always evaluates to true}}
10 if ((x | 4) == 3) {} // expected-warning {{bitwise comparison always evaluates to false}}
11 if ((x | 3) != 4) {} // expected-warning {{bitwise comparison always evaluates to true}}
12 if ((5 | x) != 3) {} // expected-warning {{bitwise comparison always evaluates to true}}
13 if ((x & 0x15) == 0x13) {} // expected-warning {{bitwise comparison always evaluates to false}}
14 if ((0x23 | x) == 0x155){} // expected-warning {{bitwise comparison always evaluates to false}}
15
16 if ((x & 8) == 8) {}
17 if ((x & 8) != 8) {}
18 if ((x | 4) == 4) {}
19 if ((x | 4) != 4) {}
20
21 if ((x & 9) == 8) {}
22 if ((x & 9) != 8) {}
23 if ((x | 4) == 5) {}
24 if ((x | 4) != 5) {}
25
26 if ((x & mydefine) == 8) {}
27 if ((x | mydefine) == 4) {}
28}