xref: /llvm-project/clang-tools-extra/test/clang-tidy/checkers/hicpp/signed-bitwise-bug34747.cpp (revision 89a1d03e2b379e325daa5249411e414bbd995b5e)
1*89a1d03eSRichard // RUN: %check_clang_tidy %s hicpp-signed-bitwise %t --
2*89a1d03eSRichard 
3*89a1d03eSRichard // Note: this test expects no diagnostics, but FileCheck cannot handle that,
4*89a1d03eSRichard // hence the use of | count 0.
5*89a1d03eSRichard 
6*89a1d03eSRichard template <typename C>
7*89a1d03eSRichard struct OutputStream {
8*89a1d03eSRichard   OutputStream &operator<<(C);
9*89a1d03eSRichard };
10*89a1d03eSRichard 
11*89a1d03eSRichard template <typename C>
12*89a1d03eSRichard struct foo {
13*89a1d03eSRichard   typedef OutputStream<C> stream_type;
foofoo14*89a1d03eSRichard   foo(stream_type &o) {
15*89a1d03eSRichard     o << 'x'; // warning occurred here, fixed now
16*89a1d03eSRichard   }
17*89a1d03eSRichard };
18*89a1d03eSRichard 
bar(OutputStream<signed char> & o)19*89a1d03eSRichard void bar(OutputStream<signed char> &o) {
20*89a1d03eSRichard   foo<signed char> f(o);
21*89a1d03eSRichard }
22*89a1d03eSRichard 
silence_lit()23*89a1d03eSRichard void silence_lit() {
24*89a1d03eSRichard   int SValue = 42;
25*89a1d03eSRichard   int SResult;
26*89a1d03eSRichard 
27*89a1d03eSRichard   SResult = SValue & 1;
28*89a1d03eSRichard   // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
29*89a1d03eSRichard }
30