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-unknown-unknown-x c++ -funsigned-char
9 
t0(char a,char b)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 }
t1(char a,char b)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 
t2(unsigned char a,char b)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 }
t3(unsigned char a,char b)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 
t4(char a,unsigned char b)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 }
t5(char a,unsigned char b)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 
t6(unsigned char a,unsigned char b)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 }
t7(unsigned char a,unsigned char b)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 
t8(signed char a,char b)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 }
t9(signed char a,char b)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 
t10(char a,signed char b)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 }
t11(char a,signed char b)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 
t12(signed char a,signed char b)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 }
t13(signed char a,signed char b)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 }
100