1 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify %s -Wabsolute-value
2 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only %s -Wabsolute-value -fdiagnostics-parseable-fixits 2>&1 | FileCheck %s
14 void test(long long ll
, double d
, int i
, float f
) {
15 // Suggest including cmath
17 // expected-warning@-1{{using integer absolute value function 'abs' when argument is of floating point type}}
18 // expected-note@-2{{use function 'std::abs' instead}}
19 // expected-note@-3{{include the header <cmath> or explicitly provide a declaration for 'std::abs'}}
20 // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:12}:"std::abs"
23 // 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}}
24 // expected-note@-2{{use function 'std::abs' instead}}
25 // expected-note@-3{{include the header <cmath> or explicitly provide a declaration for 'std::abs'}}
26 // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:14}:"std::abs"
28 // Suggest including cstdlib
30 // 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}}
31 // expected-note@-2{{use function 'std::abs' instead}}
32 // expected-note@-3{{include the header <cstdlib> or explicitly provide a declaration for 'std::abs'}}
33 // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:12}:"std::abs"
35 // expected-warning@-1{{using floating point absolute value function 'fabsf' when argument is of integer type}}
36 // expected-note@-2{{use function 'std::abs' instead}}
37 // expected-note@-3{{include the header <cstdlib> or explicitly provide a declaration for 'std::abs'}}
38 // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:14}:"std::abs"
40 // Proper function already called, no warnings.
44 // Declarations found, suggest name change.
46 // expected-warning@-1{{using floating point absolute value function 'fabsf' when argument is of integer type}}
47 // expected-note@-2{{use function 'std::abs' instead}}
48 // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
50 // expected-warning@-1{{using integer absolute value function 'abs' when argument is of floating point type}}
51 // expected-note@-2{{use function 'std::abs' instead}}
52 // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"std::abs"