summaryrefslogtreecommitdiff
path: root/test/SemaCXX/warn-bitwise-compare.cpp
blob: 894d4c581e6f0813f1f1ce50b945ca771f371b08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
// RUN: %clang_cc1 -fsyntax-only -verify -Wtautological-bitwise-compare %s

void test(int x) {
  bool b1 = (8 & x) == 3;
  // expected-warning@-1 {{bitwise comparison always evaluates to false}}
  bool b2 = x | 5;
  // expected-warning@-1 {{bitwise or with non-zero value always evaluates to true}}
  bool b3 = (x | 5);
  // expected-warning@-1 {{bitwise or with non-zero value always evaluates to true}}
  bool b4 = !!(x | 5);
  // expected-warning@-1 {{bitwise or with non-zero value always evaluates to true}}
}