brintos

brintos / llvm-project-archived public Read only

0
0
Text · 941 B · 28b926e Raw
25 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify -Wtautological-bitwise-compare %s2// RUN: %clang_cc1 -fsyntax-only -verify -Wall -Wno-unused %s3 4void test(int x) {5  bool b1 = (8 & x) == 3;6  // expected-warning@-1 {{bitwise comparison always evaluates to false}}7  bool b2 = x | 5;8  // expected-warning@-1 {{bitwise or with non-zero value always evaluates to true}}9  bool b3 = (x | 5);10  // expected-warning@-1 {{bitwise or with non-zero value always evaluates to true}}11  bool b4 = !!(x | 5);12  // expected-warning@-1 {{bitwise or with non-zero value always evaluates to true}}13}14 15template <int I, class T>  // silence16void foo(int x) {17    bool b1 = (x & sizeof(T)) == 8;18    bool b2 = (x & I) == 8;19    bool b3 = (x & 4) == 8; // expected-warning {{bitwise comparison always evaluates to false}}20}21 22void run(int x) {23    foo<4, int>(8); // expected-note {{in instantiation of function template specialization 'foo<4, int>' requested here}}24}25