void* ber_memcpy_safe(void* dest, const void* src, size_t n) { long diff = (char*) dest - (char*) src; if (unlikely(n > (size_t) __builtin_labs(diff))) { if (unlikely(src == dest)) return dest; if (reopenldap_mode_check()) __ldap_assert_fail("source and destination MUST NOT overlap", __FILE__, __LINE__, __FUNCTION__); return memmove(dest, src, n); } return memcpy(dest, src, n); }
void test_long(long x) { (void)abs(x); // no warning - int and long are same length for this target (void)labs(x); (void)llabs(x); (void)fabsf(x); // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}} // expected-note@-2 {{use function 'labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs" (void)fabs(x); // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}} // expected-note@-2 {{use function 'labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"labs" (void)fabsl(x); // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}} // expected-note@-2 {{use function 'labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs" (void)cabsf(x); // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}} // expected-note@-2 {{use function 'labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs" (void)cabs(x); // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}} // expected-note@-2 {{use function 'labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"labs" (void)cabsl(x); // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}} // expected-note@-2 {{use function 'labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs" (void)__builtin_abs(x); // no warning - int and long are same length for // this target (void)__builtin_labs(x); (void)__builtin_llabs(x); (void)__builtin_fabsf(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs" (void)__builtin_fabs(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_labs" (void)__builtin_fabsl(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs" (void)__builtin_cabsf(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs" (void)__builtin_cabs(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_labs" (void)__builtin_cabsl(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_labs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs" }
void test_unsigned_long(unsigned long x) { (void)abs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'abs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"" (void)labs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'labs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"" (void)llabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'llabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"" (void)fabsf(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'fabsf' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"" (void)fabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'fabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"" (void)fabsl(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'fabsl' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"" (void)cabsf(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'cabsf' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"" (void)cabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'cabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"" (void)cabsl(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to 'cabsl' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"" (void)__builtin_abs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_abs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"" (void)__builtin_labs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_labs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"" (void)__builtin_llabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_llabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"" (void)__builtin_fabsf(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_fabsf' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"" (void)__builtin_fabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_fabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"" (void)__builtin_fabsl(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_fabsl' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"" (void)__builtin_cabsf(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_cabsf' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"" (void)__builtin_cabs(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_cabs' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"" (void)__builtin_cabsl(x); // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}} // expected-note@-2 {{remove the call to '__builtin_cabsl' since unsigned values cannot be negative}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"" }
void test_complex_long_double(_Complex long double x) { (void)abs(x); // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabsl" (void)labs(x); // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl" (void)llabs(x); // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl" (void)fabsf(x); // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of complex type}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl" (void)fabs(x); // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl" (void)fabsl(x); // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of complex type}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl" (void)cabsf(x); // 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}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl" (void)cabs(x); // 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}} // expected-note@-2 {{use function 'cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl" (void)cabsl(x); (void)__builtin_abs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_cabsl" (void)__builtin_labs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl" (void)__builtin_llabs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl" (void)__builtin_fabsf(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl" (void)__builtin_fabs(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl" (void)__builtin_fabsl(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl" (void)__builtin_cabsf(x); // 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}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl" (void)__builtin_cabs(x); // 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}} // expected-note@-2 {{use function '__builtin_cabsl' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl" (void)__builtin_cabsl(x); }
void test_complex_float(_Complex float x) { (void)abs(x); // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabsf" (void)labs(x); // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsf" (void)llabs(x); // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf" (void)fabsf(x); // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of complex type}} // expected-note@-2 {{use function 'cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf" (void)fabs(x); // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of complex type}} // expected-note@-2 {{use function 'cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsf" (void)fabsl(x); // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of complex type}} // expected-note@-2 {{use function 'cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf" (void)cabsf(x); (void)cabs(x); (void)cabsl(x); (void)__builtin_abs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_cabsf" (void)__builtin_labs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsf" (void)__builtin_llabs(x); // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf" (void)__builtin_fabsf(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf" (void)__builtin_fabs(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsf" (void)__builtin_fabsl(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of complex type}} // expected-note@-2 {{use function '__builtin_cabsf' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf" (void)__builtin_cabsf(x); (void)__builtin_cabs(x); (void)__builtin_cabsl(x); }
void test_long_long(long long x) { (void)abs(x); // 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}} // expected-note@-2{{use function 'llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"llabs" (void)labs(x); // 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}} // expected-note@-2{{use function 'llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"llabs" (void)llabs(x); (void)fabsf(x); // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}} // expected-note@-2 {{use function 'llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs" (void)fabs(x); // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}} // expected-note@-2 {{use function 'llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"llabs" (void)fabsl(x); // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}} // expected-note@-2 {{use function 'llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs" (void)cabsf(x); // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}} // expected-note@-2 {{use function 'llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs" (void)cabs(x); // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}} // expected-note@-2 {{use function 'llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"llabs" (void)cabsl(x); // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}} // expected-note@-2 {{use function 'llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs" (void)__builtin_abs(x); // 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}} // expected-note@-2{{use function '__builtin_llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_llabs" (void)__builtin_labs(x); // 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}} // expected-note@-2{{use function '__builtin_llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_llabs" (void)__builtin_llabs(x); (void)__builtin_fabsf(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs" (void)__builtin_fabs(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_llabs" (void)__builtin_fabsl(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs" (void)__builtin_cabsf(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs" (void)__builtin_cabs(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_llabs" (void)__builtin_cabsl(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}} // expected-note@-2 {{use function '__builtin_llabs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs" }
void test_int(int x) { (void)std::abs(x); (void)abs(x); (void)labs(x); (void)llabs(x); (void)fabsf(x); // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)fabs(x); // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs" (void)fabsl(x); // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)cabsf(x); // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)cabs(x); // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs" (void)cabsl(x); // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs" (void)__builtin_abs(x); (void)__builtin_labs(x); (void)__builtin_llabs(x); (void)__builtin_fabsf(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_fabs(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs" (void)__builtin_fabsl(x); // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_cabsf(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" (void)__builtin_cabs(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs" (void)__builtin_cabsl(x); // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}} // expected-note@-2 {{use function 'std::abs' instead}} // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs" }
void main_test (void) { /* For each type, test both runtime and compile time (constant folding) optimization. */ volatile int i0 = 0, i1 = 1, im1 = -1, imin = -INT_MAX, imax = INT_MAX; volatile long l0 = 0L, l1 = 1L, lm1 = -1L, lmin = -LONG_MAX, lmax = LONG_MAX; volatile long long ll0 = 0LL, ll1 = 1LL, llm1 = -1LL; volatile long long llmin = -__LONG_LONG_MAX__, llmax = __LONG_LONG_MAX__; volatile intmax_t imax0 = 0, imax1 = 1, imaxm1 = -1; volatile intmax_t imaxmin = -INTMAX_MAX, imaxmax = INTMAX_MAX; if (__builtin_abs (i0) != 0) abort (); if (__builtin_abs (0) != 0) link_error (); if (__builtin_abs (i1) != 1) abort (); if (__builtin_abs (1) != 1) link_error (); if (__builtin_abs (im1) != 1) abort (); if (__builtin_abs (-1) != 1) link_error (); if (__builtin_abs (imin) != INT_MAX) abort (); if (__builtin_abs (-INT_MAX) != INT_MAX) link_error (); if (__builtin_abs (imax) != INT_MAX) abort (); if (__builtin_abs (INT_MAX) != INT_MAX) link_error (); if (__builtin_labs (l0) != 0L) abort (); if (__builtin_labs (0L) != 0L) link_error (); if (__builtin_labs (l1) != 1L) abort (); if (__builtin_labs (1L) != 1L) link_error (); if (__builtin_labs (lm1) != 1L) abort (); if (__builtin_labs (-1L) != 1L) link_error (); if (__builtin_labs (lmin) != LONG_MAX) abort (); if (__builtin_labs (-LONG_MAX) != LONG_MAX) link_error (); if (__builtin_labs (lmax) != LONG_MAX) abort (); if (__builtin_labs (LONG_MAX) != LONG_MAX) link_error (); if (__builtin_llabs (ll0) != 0LL) abort (); if (__builtin_llabs (0LL) != 0LL) link_error (); if (__builtin_llabs (ll1) != 1LL) abort (); if (__builtin_llabs (1LL) != 1LL) link_error (); if (__builtin_llabs (llm1) != 1LL) abort (); if (__builtin_llabs (-1LL) != 1LL) link_error (); if (__builtin_llabs (llmin) != __LONG_LONG_MAX__) abort (); if (__builtin_llabs (-__LONG_LONG_MAX__) != __LONG_LONG_MAX__) link_error (); if (__builtin_llabs (llmax) != __LONG_LONG_MAX__) abort (); if (__builtin_llabs (__LONG_LONG_MAX__) != __LONG_LONG_MAX__) link_error (); if (__builtin_imaxabs (imax0) != 0) abort (); if (__builtin_imaxabs (0) != 0) link_error (); if (__builtin_imaxabs (imax1) != 1) abort (); if (__builtin_imaxabs (1) != 1) link_error (); if (__builtin_imaxabs (imaxm1) != 1) abort (); if (__builtin_imaxabs (-1) != 1) link_error (); if (__builtin_imaxabs (imaxmin) != INTMAX_MAX) abort (); if (__builtin_imaxabs (-INTMAX_MAX) != INTMAX_MAX) link_error (); if (__builtin_imaxabs (imaxmax) != INTMAX_MAX) abort (); if (__builtin_imaxabs (INTMAX_MAX) != INTMAX_MAX) link_error (); }