llvm-project/clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-...

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
1.5 KiB
C++
Raw Normal View History

2021-04-14 02:21:19 +08:00
// RUN: %check_clang_tidy -std=c99 %s bugprone-implicit-widening-of-multiplication-result %t -- -- -target x86_64-unknown-unknown -x c
// RUN: %check_clang_tidy %s bugprone-implicit-widening-of-multiplication-result %t -- -- -target x86_64-unknown-unknown -x c++
_BitInt(64) t0(_BitInt(32) a, _BitInt(32) b) {
2021-04-14 02:21:19 +08:00
return a * b;
// CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type '_BitInt(64)' of a multiplication performed in type '_BitInt(32)'
2021-04-14 02:21:19 +08:00
// CHECK-NOTES: :[[@LINE-2]]:10: note: make conversion explicit to silence this warning
// CHECK-NOTES: :[[@LINE-3]]:10: note: perform multiplication in a wider type
}
unsigned _BitInt(64) t1(_BitInt(32) a, _BitInt(32) b) {
2021-04-14 02:21:19 +08:00
return a * b;
// CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type 'unsigned _BitInt(64)' of a multiplication performed in type '_BitInt(32)'
2021-04-14 02:21:19 +08:00
// CHECK-NOTES: :[[@LINE-2]]:10: note: make conversion explicit to silence this warning
// CHECK-NOTES: :[[@LINE-3]]:10: note: perform multiplication in a wider type
}
_BitInt(64) t2(unsigned _BitInt(32) a, unsigned _BitInt(32) b) {
2021-04-14 02:21:19 +08:00
return a * b;
// CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type '_BitInt(64)' of a multiplication performed in type 'unsigned _BitInt(32)'
2021-04-14 02:21:19 +08:00
// CHECK-NOTES: :[[@LINE-2]]:10: note: make conversion explicit to silence this warning
// CHECK-NOTES: :[[@LINE-3]]:10: note: perform multiplication in a wider type
}