Skip to content

Commit 00df49d

Browse files
committed
template test
1 parent 7f6405e commit 00df49d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

clang-tools-extra/test/clang-tidy/checkers/bugprone/unintended-char-ostream-output.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,23 @@ void template_based_on_ostream(B<int> &os) {
7171
// CHECK-MESSAGES: [[@LINE-1]]:6: warning: 'unsigned char' passed to 'operator<<' outputs as character instead of integer
7272
}
7373

74+
template<class T> void template_fn_1(T &os) {
75+
unsigned char unsigned_value = 9;
76+
os << unsigned_value;
77+
// CHECK-MESSAGES: [[@LINE-1]]:6: warning: 'unsigned char' passed to 'operator<<' outputs as character instead of integer
78+
}
79+
template<class T> void template_fn_2(std::ostream &os) {
80+
T unsigned_value = 9;
81+
os << unsigned_value;
82+
// CHECK-MESSAGES: [[@LINE-1]]:6: warning: 'unsigned char' passed to 'operator<<' outputs as character instead of integer
83+
}
84+
template<class T> void template_fn_3(std::ostream &os) {
85+
T unsigned_value = 9;
86+
os << unsigned_value;
87+
}
88+
void call_template_fn() {
89+
A a{};
90+
template_fn_1(a);
91+
template_fn_2<unsigned char>(a);
92+
template_fn_3<char>(a);
93+
}

0 commit comments

Comments
 (0)