| 1 |
// RUN: %check_clang_tidy -std=c99 %s bugprone-implicit-widening-of-multiplication-result %t -- -- -target x86_64-unknown-unknown -x c |
| 2 |
// RUN: %check_clang_tidy %s bugprone-implicit-widening-of-multiplication-result %t -- -- -target x86_64-unknown-unknown -x c++ |
| 3 |
|
| 4 |
// RUN: %check_clang_tidy -std=c99 %s bugprone-implicit-widening-of-multiplication-result %t -- -- -target x86_64-unknown-unknown -x c -fsigned-char |
| 5 |
// RUN: %check_clang_tidy %s bugprone-implicit-widening-of-multiplication-result %t -- -- -target x86_64-unknown-unknown -x c++ -fsigned-char |
| 6 |
|
| 7 |
// RUN: %check_clang_tidy -std=c99 %s bugprone-implicit-widening-of-multiplication-result %t -- -- -target x86_64-unknown-unknown -x c -funsigned-char |
| 8 |
// RUN: %check_clang_tidy %s bugprone-implicit-widening-of-multiplication-result %t -- -- -target x86_64 c++ -funsigned-char |
| 9 |
|
| 10 |
long t0(char a, char b) { |
| 11 |
return a * b; |
| 12 |
// CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type 'long' of a multiplication performed in type 'int' |
| 13 |
// CHECK-NOTES: :[[@LINE-2]]:10: note: make conversion explicit to silence this warning |
| 14 |
// CHECK-NOTES: :[[@LINE-3]]:10: note: perform multiplication in a wider type |
| 15 |
} |
| 16 |
unsigned long t1(char a, char b) { |
| 17 |
return a * b; |
| 18 |
// CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type 'unsigned long' of a multiplication performed in type 'int' |
| 19 |
// CHECK-NOTES: :[[@LINE-2]]:10: note: make conversion explicit to silence this warning |
| 20 |
// CHECK-NOTES: :[[@LINE-3]]:10: note: perform multiplication in a wider type |
| 21 |
} |
| 22 |
|
| 23 |
long t2(unsigned char a, char b) { |
| 24 |
return a * b; |
| 25 |
// CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type 'long' of a multiplication performed in type 'int' |
| 26 |
// CHECK-NOTES: :[[@LINE-2]]:10: note: make conversion explicit to silence this warning |
| 27 |
// CHECK-NOTES: :[[@LINE-3]]:10: note: perform multiplication in a wider type |
| 28 |
} |
| 29 |
unsigned long t3(unsigned char a, char b) { |
| 30 |
return a * b; |
| 31 |
// CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type 'unsigned long' of a multiplication performed in type 'int' |
| 32 |
// CHECK-NOTES: :[[@LINE-2]]:10: note: make conversion explicit to silence this warning |
| 33 |
// CHECK-NOTES: :[[@LINE-3]]:10: note: perform multiplication in a wider type |
| 34 |
} |
| 35 |
|
| 36 |
long t4(char a, unsigned char b) { |
| 37 |
return a * b; |
| 38 |
// CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type 'long' of a multiplication performed in type 'int' |
| 39 |
// CHECK-NOTES: :[[@LINE-2]]:10: note: make conversion explicit to silence this warning |
| 40 |
// CHECK-NOTES: :[[@LINE-3]]:10: note: perform multiplication in a wider type |
| 41 |
} |
| 42 |
unsigned long t5(char a, unsigned char b) { |
| 43 |
return a * b; |
| 44 |
// CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type 'unsigned long' of a multiplication performed in type 'int' |
| 45 |
// CHECK-NOTES: :[[@LINE-2]]:10: note: make conversion explicit to silence this warning |
| 46 |
// CHECK-NOTES: :[[@LINE-3]]:10: note: perform multiplication in a wider type |
| 47 |
} |
| 48 |
|
| 49 |
long t6(unsigned char a, unsigned char b) { |
| 50 |
return a * b; |
| 51 |
// CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type 'long' of a multiplication performed in type 'int' |
| 52 |
// CHECK-NOTES: :[[@LINE-2]]:10: note: make conversion explicit to silence this warning |
| 53 |
// CHECK-NOTES: :[[@LINE-3]]:10: note: perform multiplication in a wider type |
| 54 |
} |
| 55 |
unsigned long t7(unsigned char a, unsigned char b) { |
| 56 |
return a * b; |
| 57 |
// CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type 'unsigned long' of a multiplication performed in type 'int' |
| 58 |
// CHECK-NOTES: :[[@LINE-2]]:10: note: make conversion explicit to silence this warning |
| 59 |
// CHECK-NOTES: :[[@LINE-3]]:10: note: perform multiplication in a wider type |
| 60 |
} |
| 61 |
|
| 62 |
long t8(signed char a, char b) { |
| 63 |
return a * b; |
| 64 |
// CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type 'long' of a multiplication performed in type 'int' |
| 65 |
// CHECK-NOTES: :[[@LINE-2]]:10: note: make conversion explicit to silence this warning |
| 66 |
// CHECK-NOTES: :[[@LINE-3]]:10: note: perform multiplication in a wider type |
| 67 |
} |
| 68 |
unsigned long t9(signed char a, char b) { |
| 69 |
return a * b; |
| 70 |
// CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type 'unsigned long' of a multiplication performed in type 'int' |
| 71 |
// CHECK-NOTES: :[[@LINE-2]]:10: note: make conversion explicit to silence this warning |
| 72 |
// CHECK-NOTES: :[[@LINE-3]]:10: note: perform multiplication in a wider type |
| 73 |
} |
| 74 |
|
| 75 |
long t10(char a, signed char b) { |
| 76 |
return a * b; |
| 77 |
// CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type 'long' of a multiplication performed in type 'int' |
| 78 |
// CHECK-NOTES: :[[@LINE-2]]:10: note: make conversion explicit to silence this warning |
| 79 |
// CHECK-NOTES: :[[@LINE-3]]:10: note: perform multiplication in a wider type |
| 80 |
} |
| 81 |
unsigned long t11(char a, signed char b) { |
| 82 |
return a * b; |
| 83 |
// CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type 'unsigned long' of a multiplication performed in type 'int' |
| 84 |
// CHECK-NOTES: :[[@LINE-2]]:10: note: make conversion explicit to silence this warning |
| 85 |
// CHECK-NOTES: :[[@LINE-3]]:10: note: perform multiplication in a wider type |
| 86 |
} |
| 87 |
|
| 88 |
long t12(signed char a, signed char b) { |
| 89 |
return a * b; |
| 90 |
// CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type 'long' of a multiplication performed in type 'int' |
| 91 |
// CHECK-NOTES: :[[@LINE-2]]:10: note: make conversion explicit to silence this warning |
| 92 |
// CHECK-NOTES: :[[@LINE-3]]:10: note: perform multiplication in a wider type |
| 93 |
} |
| 94 |
unsigned long t13(signed char a, signed char b) { |
| 95 |
return a * b; |
| 96 |
// CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type 'unsigned long' of a multiplication performed in type 'int' |
| 97 |
// CHECK-NOTES: :[[@LINE-2]]:10: note: make conversion explicit to silence this warning |
| 98 |
// CHECK-NOTES: :[[@LINE-3]]:10: note: perform multiplication in a wider type |
| 99 |
} |