1 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify %s -Wabsolute-value -std=c++11
2 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only %s -Wabsolute-value -fdiagnostics-parseable-fixits -std=c++11 2>&1 | FileCheck %s
3 
4 extern "C" {
5 int abs(int);
6 long int labs(long int);
7 long long int llabs(long long int);
8 
9 float fabsf(float);
10 double fabs(double);
11 long double fabsl(long double);
12 
13 float cabsf(float _Complex);
14 double cabs(double _Complex);
15 long double cabsl(long double _Complex);
16 }
17 
18 namespace std {
19 
20 inline namespace __1 {
21 int abs(int);
22 long int abs(long int);
23 long long int abs(long long int);
24 }
25 
26 float abs(float);
27 double abs(double);
28 long double abs(long double);
29 
30 template <typename T>
31 double abs(T);
32 
33 }
34 
test_int(int x)35 void test_int(int x) {
36   (void)std::abs(x);
37 
38   (void)abs(x);
39   (void)labs(x);
40   (void)llabs(x);
41 
42   (void)fabsf(x);
43   // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}}
44   // expected-note@-2 {{use function 'std::abs' instead}}
45   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
46   (void)fabs(x);
47   // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}}
48   // expected-note@-2 {{use function 'std::abs' instead}}
49   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
50   (void)fabsl(x);
51   // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}}
52   // expected-note@-2 {{use function 'std::abs' instead}}
53   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
54 
55   (void)cabsf(x);
56   // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}}
57   // expected-note@-2 {{use function 'std::abs' instead}}
58   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
59   (void)cabs(x);
60   // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}}
61   // expected-note@-2 {{use function 'std::abs' instead}}
62   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
63   (void)cabsl(x);
64   // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}}
65   // expected-note@-2 {{use function 'std::abs' instead}}
66   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
67 
68   (void)__builtin_abs(x);
69   (void)__builtin_labs(x);
70   (void)__builtin_llabs(x);
71 
72   (void)__builtin_fabsf(x);
73   // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}}
74   // expected-note@-2 {{use function 'std::abs' instead}}
75   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
76   (void)__builtin_fabs(x);
77   // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}}
78   // expected-note@-2 {{use function 'std::abs' instead}}
79   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
80   (void)__builtin_fabsl(x);
81   // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}}
82   // expected-note@-2 {{use function 'std::abs' instead}}
83   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
84 
85   (void)__builtin_cabsf(x);
86   // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}}
87   // expected-note@-2 {{use function 'std::abs' instead}}
88   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
89   (void)__builtin_cabs(x);
90   // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}}
91   // expected-note@-2 {{use function 'std::abs' instead}}
92   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
93   (void)__builtin_cabsl(x);
94   // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}}
95   // expected-note@-2 {{use function 'std::abs' instead}}
96   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
97 }
98 
test_long(long x)99 void test_long(long x) {
100   (void)std::abs(x);
101 
102   (void)abs(x);  // no warning - int and long are same length for this target
103   (void)labs(x);
104   (void)llabs(x);
105 
106   (void)fabsf(x);
107   // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}}
108   // expected-note@-2 {{use function 'std::abs' instead}}
109   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
110   (void)fabs(x);
111   // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}}
112   // expected-note@-2 {{use function 'std::abs' instead}}
113   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
114   (void)fabsl(x);
115   // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}}
116   // expected-note@-2 {{use function 'std::abs' instead}}
117   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
118 
119   (void)cabsf(x);
120   // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}}
121   // expected-note@-2 {{use function 'std::abs' instead}}
122   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
123   (void)cabs(x);
124   // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}}
125   // expected-note@-2 {{use function 'std::abs' instead}}
126   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
127   (void)cabsl(x);
128   // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}}
129   // expected-note@-2 {{use function 'std::abs' instead}}
130   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
131 
132   (void)__builtin_abs(x);  // no warning - int and long are same length for
133                            // this target
134   (void)__builtin_labs(x);
135   (void)__builtin_llabs(x);
136 
137   (void)__builtin_fabsf(x);
138   // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}}
139   // expected-note@-2 {{use function 'std::abs' instead}}
140   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
141   (void)__builtin_fabs(x);
142   // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}}
143   // expected-note@-2 {{use function 'std::abs' instead}}
144   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
145   (void)__builtin_fabsl(x);
146   // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}}
147   // expected-note@-2 {{use function 'std::abs' instead}}
148   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
149 
150   (void)__builtin_cabsf(x);
151   // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}}
152   // expected-note@-2 {{use function 'std::abs' instead}}
153   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
154   (void)__builtin_cabs(x);
155   // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}}
156   // expected-note@-2 {{use function 'std::abs' instead}}
157   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
158   (void)__builtin_cabsl(x);
159   // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}}
160   // expected-note@-2 {{use function 'std::abs' instead}}
161   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
162 }
163 
test_long_long(long long x)164 void test_long_long(long long x) {
165   (void)std::abs(x);
166 
167   (void)abs(x);
168   // expected-warning@-1{{absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value}}
169   // expected-note@-2{{use function 'std::abs' instead}}
170   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"std::abs"
171   (void)labs(x);
172   // expected-warning@-1{{absolute value function 'labs' given an argument of type 'long long' but has parameter of type 'long' which may cause truncation of value}}
173   // expected-note@-2{{use function 'std::abs' instead}}
174   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
175   (void)llabs(x);
176 
177   (void)fabsf(x);
178   // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}}
179   // expected-note@-2 {{use function 'std::abs' instead}}
180   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
181   (void)fabs(x);
182   // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}}
183   // expected-note@-2 {{use function 'std::abs' instead}}
184   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
185   (void)fabsl(x);
186   // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}}
187   // expected-note@-2 {{use function 'std::abs' instead}}
188   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
189 
190   (void)cabsf(x);
191   // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}}
192   // expected-note@-2 {{use function 'std::abs' instead}}
193   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
194   (void)cabs(x);
195   // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}}
196   // expected-note@-2 {{use function 'std::abs' instead}}
197   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
198   (void)cabsl(x);
199   // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}}
200   // expected-note@-2 {{use function 'std::abs' instead}}
201   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
202 
203   (void)__builtin_abs(x);
204   // expected-warning@-1{{absolute value function '__builtin_abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value}}
205   // expected-note@-2{{use function 'std::abs' instead}}
206   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"std::abs"
207   (void)__builtin_labs(x);
208   // expected-warning@-1{{absolute value function '__builtin_labs' given an argument of type 'long long' but has parameter of type 'long' which may cause truncation of value}}
209   // expected-note@-2{{use function 'std::abs' instead}}
210   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
211   (void)__builtin_llabs(x);
212 
213   (void)__builtin_fabsf(x);
214   // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}}
215   // expected-note@-2 {{use function 'std::abs' instead}}
216   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
217   (void)__builtin_fabs(x);
218   // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}}
219   // expected-note@-2 {{use function 'std::abs' instead}}
220   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
221   (void)__builtin_fabsl(x);
222   // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}}
223   // expected-note@-2 {{use function 'std::abs' instead}}
224   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
225 
226   (void)__builtin_cabsf(x);
227   // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}}
228   // expected-note@-2 {{use function 'std::abs' instead}}
229   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
230   (void)__builtin_cabs(x);
231   // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}}
232   // expected-note@-2 {{use function 'std::abs' instead}}
233   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
234   (void)__builtin_cabsl(x);
235   // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}}
236   // expected-note@-2 {{use function 'std::abs' instead}}
237   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
238 }
239 
test_float(float x)240 void test_float(float x) {
241   (void)std::abs(x);
242 
243   (void)abs(x);
244   // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of floating point type}}
245   // expected-note@-2 {{use function 'std::abs' instead}}
246   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"std::abs"
247   (void)labs(x);
248   // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of floating point type}}
249   // expected-note@-2 {{use function 'std::abs' instead}}
250   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
251   (void)llabs(x);
252   // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of floating point type}}
253   // expected-note@-2 {{use function 'std::abs' instead}}
254   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
255 
256   (void)fabsf(x);
257   (void)fabs(x);
258   (void)fabsl(x);
259 
260   (void)cabsf(x);
261   // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of floating point type}}
262   // expected-note@-2 {{use function 'std::abs' instead}}
263   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
264   (void)cabs(x);
265   // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of floating point type}}
266   // expected-note@-2 {{use function 'std::abs' instead}}
267   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
268   (void)cabsl(x);
269   // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of floating point type}}
270   // expected-note@-2 {{use function 'std::abs' instead}}
271   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
272 
273   (void)__builtin_abs(x);
274   // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of floating point type}}
275   // expected-note@-2 {{use function 'std::abs' instead}}
276   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"std::abs"
277   (void)__builtin_labs(x);
278   // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of floating point type}}
279   // expected-note@-2 {{use function 'std::abs' instead}}
280   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
281   (void)__builtin_llabs(x);
282   // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of floating point type}}
283   // expected-note@-2 {{use function 'std::abs' instead}}
284   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
285 
286   (void)__builtin_fabsf(x);
287   (void)__builtin_fabs(x);
288   (void)__builtin_fabsl(x);
289 
290   (void)__builtin_cabsf(x);
291   // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of floating point type}}
292   // expected-note@-2 {{use function 'std::abs' instead}}
293   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
294   (void)__builtin_cabs(x);
295   // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of floating point type}}
296   // expected-note@-2 {{use function 'std::abs' instead}}
297   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
298   (void)__builtin_cabsl(x);
299   // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of floating point type}}
300   // expected-note@-2 {{use function 'std::abs' instead}}
301   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
302 }
303 
test_double(double x)304 void test_double(double x) {
305   (void)std::abs(x);
306 
307   (void)abs(x);
308   // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of floating point type}}
309   // expected-note@-2 {{use function 'std::abs' instead}}
310   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"std::abs"
311   (void)labs(x);
312   // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of floating point type}}
313   // expected-note@-2 {{use function 'std::abs' instead}}
314   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
315   (void)llabs(x);
316   // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of floating point type}}
317   // expected-note@-2 {{use function 'std::abs' instead}}
318   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
319 
320   (void)fabsf(x);
321   // expected-warning@-1{{absolute value function 'fabsf' given an argument of type 'double' but has parameter of type 'float' which may cause truncation of value}}
322   // expected-note@-2{{use function 'std::abs' instead}}
323   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
324   (void)fabs(x);
325   (void)fabsl(x);
326 
327   (void)cabsf(x);
328   // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of floating point type}}
329   // expected-note@-2 {{use function 'std::abs' instead}}
330   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
331   (void)cabs(x);
332   // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of floating point type}}
333   // expected-note@-2 {{use function 'std::abs' instead}}
334   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
335   (void)cabsl(x);
336   // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of floating point type}}
337   // expected-note@-2 {{use function 'std::abs' instead}}
338   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
339 
340   (void)__builtin_abs(x);
341   // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of floating point type}}
342   // expected-note@-2 {{use function 'std::abs' instead}}
343   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"std::abs"
344   (void)__builtin_labs(x);
345   // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of floating point type}}
346   // expected-note@-2 {{use function 'std::abs' instead}}
347   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
348   (void)__builtin_llabs(x);
349   // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of floating point type}}
350   // expected-note@-2 {{use function 'std::abs' instead}}
351   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
352 
353   (void)__builtin_fabsf(x);
354   // expected-warning@-1{{absolute value function '__builtin_fabsf' given an argument of type 'double' but has parameter of type 'float' which may cause truncation of value}}
355   // expected-note@-2{{use function 'std::abs' instead}}
356   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
357   (void)__builtin_fabs(x);
358   (void)__builtin_fabsl(x);
359 
360   (void)__builtin_cabsf(x);
361   // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of floating point type}}
362   // expected-note@-2 {{use function 'std::abs' instead}}
363   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
364   (void)__builtin_cabs(x);
365   // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of floating point type}}
366   // expected-note@-2 {{use function 'std::abs' instead}}
367   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
368   (void)__builtin_cabsl(x);
369   // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of floating point type}}
370   // expected-note@-2 {{use function 'std::abs' instead}}
371   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
372 }
373 
test_long_double(long double x)374 void test_long_double(long double x) {
375   (void)std::abs(x);
376 
377   (void)abs(x);
378   // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of floating point type}}
379   // expected-note@-2 {{use function 'std::abs' instead}}
380   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"std::abs"
381   (void)labs(x);
382   // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of floating point type}}
383   // expected-note@-2 {{use function 'std::abs' instead}}
384   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
385   (void)llabs(x);
386   // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of floating point type}}
387   // expected-note@-2 {{use function 'std::abs' instead}}
388   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
389 
390   (void)fabsf(x);
391   // expected-warning@-1{{absolute value function 'fabsf' given an argument of type 'long double' but has parameter of type 'float' which may cause truncation of value}}
392   // expected-note@-2{{use function 'std::abs' instead}}
393   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
394   (void)fabs(x);
395   // expected-warning@-1{{absolute value function 'fabs' given an argument of type 'long double' but has parameter of type 'double' which may cause truncation of value}}
396   // expected-note@-2{{use function 'std::abs' instead}}
397   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
398   (void)fabsl(x);
399 
400   (void)cabsf(x);
401   // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of floating point type}}
402   // expected-note@-2 {{use function 'std::abs' instead}}
403   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
404   (void)cabs(x);
405   // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of floating point type}}
406   // expected-note@-2 {{use function 'std::abs' instead}}
407   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
408   (void)cabsl(x);
409   // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of floating point type}}
410   // expected-note@-2 {{use function 'std::abs' instead}}
411   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
412 
413   (void)__builtin_abs(x);
414   // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of floating point type}}
415   // expected-note@-2 {{use function 'std::abs' instead}}
416   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"std::abs"
417   (void)__builtin_labs(x);
418   // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of floating point type}}
419   // expected-note@-2 {{use function 'std::abs' instead}}
420   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
421   (void)__builtin_llabs(x);
422   // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of floating point type}}
423   // expected-note@-2 {{use function 'std::abs' instead}}
424   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
425 
426   (void)__builtin_fabsf(x);
427   // expected-warning@-1{{absolute value function '__builtin_fabsf' given an argument of type 'long double' but has parameter of type 'float' which may cause truncation of value}}
428   // expected-note@-2{{use function 'std::abs' instead}}
429   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
430   (void)__builtin_fabs(x);
431   // expected-warning@-1{{absolute value function '__builtin_fabs' given an argument of type 'long double' but has parameter of type 'double' which may cause truncation of value}}
432   // expected-note@-2{{use function 'std::abs' instead}}
433   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
434   (void)__builtin_fabsl(x);
435 
436   (void)__builtin_cabsf(x);
437   // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of floating point type}}
438   // expected-note@-2 {{use function 'std::abs' instead}}
439   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
440   (void)__builtin_cabs(x);
441   // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of floating point type}}
442   // expected-note@-2 {{use function 'std::abs' instead}}
443   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
444   (void)__builtin_cabsl(x);
445   // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of floating point type}}
446   // expected-note@-2 {{use function 'std::abs' instead}}
447   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
448 }
449 
test_complex_float(_Complex float x)450 void test_complex_float(_Complex float x) {
451   (void)cabsf(x);
452   (void)cabs(x);
453   (void)cabsl(x);
454 
455   (void)__builtin_cabsf(x);
456   (void)__builtin_cabs(x);
457   (void)__builtin_cabsl(x);
458 }
459 
test_complex_double(_Complex double x)460 void test_complex_double(_Complex double x) {
461   (void)cabsf(x);
462   // expected-warning@-1 {{absolute value function 'cabsf' given an argument of type '_Complex double' but has parameter of type '_Complex float' which may cause truncation of value}}
463   // expected-note@-2 {{use function 'cabs' instead}}
464   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs"
465   (void)cabs(x);
466   (void)cabsl(x);
467 
468 
469   (void)__builtin_cabsf(x);
470   // expected-warning@-1 {{absolute value function '__builtin_cabsf' given an argument of type '_Complex double' but has parameter of type '_Complex float' which may cause truncation of value}}
471   // expected-note@-2 {{use function '__builtin_cabs' instead}}
472   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs"
473   (void)__builtin_cabs(x);
474   (void)__builtin_cabsl(x);
475 }
476 
test_complex_long_double(_Complex long double x)477 void test_complex_long_double(_Complex long double x) {
478   (void)cabsf(x);
479   // expected-warning@-1 {{absolute value function 'cabsf' given an argument of type '_Complex long double' but has parameter of type '_Complex float' which may cause truncation of value}}
480   // expected-note@-2 {{use function 'cabsl' instead}}
481   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"
482   (void)cabs(x);
483   // expected-warning@-1 {{absolute value function 'cabs' given an argument of type '_Complex long double' but has parameter of type '_Complex double' which may cause truncation of value}}
484   // expected-note@-2 {{use function 'cabsl' instead}}
485   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl"
486   (void)cabsl(x);
487 
488   (void)__builtin_cabsf(x);
489   // expected-warning@-1 {{absolute value function '__builtin_cabsf' given an argument of type '_Complex long double' but has parameter of type '_Complex float' which may cause truncation of value}}
490   // expected-note@-2 {{use function '__builtin_cabsl' instead}}
491   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl"
492   (void)__builtin_cabs(x);
493   // expected-warning@-1 {{absolute value function '__builtin_cabs' given an argument of type '_Complex long double' but has parameter of type '_Complex double' which may cause truncation of value}}
494   // expected-note@-2 {{use function '__builtin_cabsl' instead}}
495   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl"
496   (void)__builtin_cabsl(x);
497 }
498 
test_unsigned_int(unsigned int x)499 void test_unsigned_int(unsigned int x) {
500   (void)std::abs(x);
501   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
502   // expected-note@-2 {{remove the call to 'std::abs' since unsigned values cannot be negative}}
503   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:17}:""
504 
505   (void)abs(x);
506   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
507   // expected-note@-2 {{remove the call to 'abs' since unsigned values cannot be negative}}
508   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:""
509   (void)labs(x);
510   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
511   // expected-note@-2 {{remove the call to 'labs' since unsigned values cannot be negative}}
512   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""
513   (void)llabs(x);
514   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
515   // expected-note@-2 {{remove the call to 'llabs' since unsigned values cannot be negative}}
516   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
517 
518   (void)fabsf(x);
519   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
520   // expected-note@-2 {{remove the call to 'fabsf' since unsigned values cannot be negative}}
521   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
522   (void)fabs(x);
523   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
524   // expected-note@-2 {{remove the call to 'fabs' since unsigned values cannot be negative}}
525   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""
526   (void)fabsl(x);
527   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
528   // expected-note@-2 {{remove the call to 'fabsl' since unsigned values cannot be negative}}
529   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
530 
531   (void)cabsf(x);
532   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
533   // expected-note@-2 {{remove the call to 'cabsf' since unsigned values cannot be negative}}
534   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
535   (void)cabs(x);
536   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
537   // expected-note@-2 {{remove the call to 'cabs' since unsigned values cannot be negative}}
538   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""
539   (void)cabsl(x);
540   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
541   // expected-note@-2 {{remove the call to 'cabsl' since unsigned values cannot be negative}}
542   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
543 
544   (void)__builtin_abs(x);
545   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
546   // expected-note@-2 {{remove the call to '__builtin_abs' since unsigned values cannot be negative}}
547   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:""
548   (void)__builtin_labs(x);
549   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
550   // expected-note@-2 {{remove the call to '__builtin_labs' since unsigned values cannot be negative}}
551   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""
552   (void)__builtin_llabs(x);
553   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
554   // expected-note@-2 {{remove the call to '__builtin_llabs' since unsigned values cannot be negative}}
555   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
556 
557   (void)__builtin_fabsf(x);
558   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
559   // expected-note@-2 {{remove the call to '__builtin_fabsf' since unsigned values cannot be negative}}
560   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
561   (void)__builtin_fabs(x);
562   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
563   // expected-note@-2 {{remove the call to '__builtin_fabs' since unsigned values cannot be negative}}
564   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""
565   (void)__builtin_fabsl(x);
566   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
567   // expected-note@-2 {{remove the call to '__builtin_fabsl' since unsigned values cannot be negative}}
568   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
569 
570   (void)__builtin_cabsf(x);
571   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
572   // expected-note@-2 {{remove the call to '__builtin_cabsf' since unsigned values cannot be negative}}
573   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
574   (void)__builtin_cabs(x);
575   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
576   // expected-note@-2 {{remove the call to '__builtin_cabs' since unsigned values cannot be negative}}
577   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""
578   (void)__builtin_cabsl(x);
579   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
580   // expected-note@-2 {{remove the call to '__builtin_cabsl' since unsigned values cannot be negative}}
581   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
582 }
583 
test_unsigned_long(unsigned long x)584 void test_unsigned_long(unsigned long x) {
585   (void)std::abs(x);
586   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
587   // expected-note@-2 {{remove the call to 'std::abs' since unsigned values cannot be negative}}
588   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:17}:""
589 
590   (void)abs(x);
591   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
592   // expected-note@-2 {{remove the call to 'abs' since unsigned values cannot be negative}}
593   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:""
594   (void)labs(x);
595   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
596   // expected-note@-2 {{remove the call to 'labs' since unsigned values cannot be negative}}
597   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""
598   (void)llabs(x);
599   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
600   // expected-note@-2 {{remove the call to 'llabs' since unsigned values cannot be negative}}
601   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
602 
603   (void)fabsf(x);
604   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
605   // expected-note@-2 {{remove the call to 'fabsf' since unsigned values cannot be negative}}
606   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
607   (void)fabs(x);
608   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
609   // expected-note@-2 {{remove the call to 'fabs' since unsigned values cannot be negative}}
610   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""
611   (void)fabsl(x);
612   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
613   // expected-note@-2 {{remove the call to 'fabsl' since unsigned values cannot be negative}}
614   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
615 
616   (void)cabsf(x);
617   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
618   // expected-note@-2 {{remove the call to 'cabsf' since unsigned values cannot be negative}}
619   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
620   (void)cabs(x);
621   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
622   // expected-note@-2 {{remove the call to 'cabs' since unsigned values cannot be negative}}
623   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""
624   (void)cabsl(x);
625   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
626   // expected-note@-2 {{remove the call to 'cabsl' since unsigned values cannot be negative}}
627   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
628 
629   (void)__builtin_abs(x);
630   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
631   // expected-note@-2 {{remove the call to '__builtin_abs' since unsigned values cannot be negative}}
632   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:""
633   (void)__builtin_labs(x);
634   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
635   // expected-note@-2 {{remove the call to '__builtin_labs' since unsigned values cannot be negative}}
636   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""
637   (void)__builtin_llabs(x);
638   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
639   // expected-note@-2 {{remove the call to '__builtin_llabs' since unsigned values cannot be negative}}
640   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
641 
642   (void)__builtin_fabsf(x);
643   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
644   // expected-note@-2 {{remove the call to '__builtin_fabsf' since unsigned values cannot be negative}}
645   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
646   (void)__builtin_fabs(x);
647   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
648   // expected-note@-2 {{remove the call to '__builtin_fabs' since unsigned values cannot be negative}}
649   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""
650   (void)__builtin_fabsl(x);
651   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
652   // expected-note@-2 {{remove the call to '__builtin_fabsl' since unsigned values cannot be negative}}
653   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
654 
655   (void)__builtin_cabsf(x);
656   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
657   // expected-note@-2 {{remove the call to '__builtin_cabsf' since unsigned values cannot be negative}}
658   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
659   (void)__builtin_cabs(x);
660   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
661   // expected-note@-2 {{remove the call to '__builtin_cabs' since unsigned values cannot be negative}}
662   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""
663   (void)__builtin_cabsl(x);
664   // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
665   // expected-note@-2 {{remove the call to '__builtin_cabsl' since unsigned values cannot be negative}}
666   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
667 }
668 
669