1 | // RUN: %check_clang_tidy %s bugprone-unintended-char-ostream-output %t -- \ |
2 | // RUN: -config="{CheckOptions: \ |
3 | // RUN: {bugprone-unintended-char-ostream-output.AllowedTypes: \"\"}}" |
4 | |
5 | namespace std { |
6 | |
7 | template <class _CharT, class _Traits = void> class basic_ostream { |
8 | public: |
9 | basic_ostream &operator<<(int); |
10 | basic_ostream &operator<<(unsigned int); |
11 | }; |
12 | |
13 | template <class CharT, class Traits> |
14 | basic_ostream<CharT, Traits> &operator<<(basic_ostream<CharT, Traits> &, CharT); |
15 | template <class CharT, class Traits> |
16 | basic_ostream<CharT, Traits> &operator<<(basic_ostream<CharT, Traits> &, char); |
17 | template <class _Traits> |
18 | basic_ostream<char, _Traits> &operator<<(basic_ostream<char, _Traits> &, char); |
19 | template <class _Traits> |
20 | basic_ostream<char, _Traits> &operator<<(basic_ostream<char, _Traits> &, |
21 | signed char); |
22 | template <class _Traits> |
23 | basic_ostream<char, _Traits> &operator<<(basic_ostream<char, _Traits> &, |
24 | unsigned char); |
25 | |
26 | using ostream = basic_ostream<char>; |
27 | |
28 | } // namespace std |
29 | |
30 | void origin_ostream(std::ostream &os) { |
31 | unsigned char unsigned_value = 9; |
32 | os << unsigned_value; |
33 | // CHECK-MESSAGES: [[@LINE-1]]:6: warning: 'unsigned char' passed to 'operator<<' outputs as character instead of integer |
34 | |
35 | signed char signed_value = 9; |
36 | os << signed_value; |
37 | // CHECK-MESSAGES: [[@LINE-1]]:6: warning: 'signed char' passed to 'operator<<' outputs as character instead of integer |
38 | |
39 | char char_value = 9; |
40 | os << char_value; |
41 | } |
42 | |