r206340 - Make -Wabsolute-value C++-aware.
Richard Trieu
rtrieu at google.com
Tue Apr 15 16:47:53 PDT 2014
Author: rtrieu
Date: Tue Apr 15 18:47:53 2014
New Revision: 206340
URL: http://llvm.org/viewvc/llvm-project?rev=206340&view=rev
Log:
Make -Wabsolute-value C++-aware.
Warn on std::abs() with unsigned argument.
Suggest std::abs as replacement for the C absolute value functions.
Suggest C++ headers if the specific std::abs overload is not found.
Added:
cfe/trunk/test/SemaCXX/warn-absolute-value.cpp
Removed:
cfe/trunk/test/SemaCXX/warn-absolute-value2.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/warn-absolute-value-header.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=206340&r1=206339&r2=206340&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Apr 15 18:47:53 2014
@@ -35,7 +35,7 @@ def warn_unsigned_abs : Warning<
"taking the absolute value of unsigned type %0 has no effect">,
InGroup<AbsoluteValue>;
def note_remove_abs : Note<
- "remove the call to %0 since unsigned values cannot be negative">;
+ "remove the call to '%0' since unsigned values cannot be negative">;
def warn_abs_too_small : Warning<
"absolute value function %0 given an argument of type %1 but has parameter "
"of type %2 which may cause truncation of value">, InGroup<AbsoluteValue>;
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=206340&r1=206339&r2=206340&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Apr 15 18:47:53 2014
@@ -3862,54 +3862,107 @@ static unsigned getAbsoluteValueFunction
// If the replacement is valid, emit a note with replacement function.
// Additionally, suggest including the proper header if not already included.
static void emitReplacement(Sema &S, SourceLocation Loc, SourceRange Range,
- unsigned AbsKind) {
- std::string AbsName = S.Context.BuiltinInfo.GetName(AbsKind);
-
- // Look up absolute value function in TU scope.
- DeclarationName DN(&S.Context.Idents.get(AbsName));
- LookupResult R(S, DN, Loc, Sema::LookupAnyName);
- R.suppressDiagnostics();
- S.LookupName(R, S.TUScope);
-
- // Skip notes if multiple results found in lookup.
- if (!R.empty() && !R.isSingleResult())
- return;
-
- FunctionDecl *FD = 0;
- bool FoundFunction = R.isSingleResult();
- // When one result is found, see if it is the correct function.
- if (R.isSingleResult()) {
- FD = dyn_cast<FunctionDecl>(R.getFoundDecl());
- if (!FD || FD->getBuiltinID() != AbsKind)
- return;
- }
+ unsigned AbsKind, QualType ArgType) {
+ bool EmitHeaderHint = true;
+ const char *HeaderName = 0;
+ const char *FunctionName = 0;
+ if (S.getLangOpts().CPlusPlus && !ArgType->isAnyComplexType()) {
+ FunctionName = "std::abs";
+ if (ArgType->isIntegralOrEnumerationType()) {
+ HeaderName = "cstdlib";
+ } else if (ArgType->isRealFloatingType()) {
+ HeaderName = "cmath";
+ } else {
+ llvm_unreachable("Invalid Type");
+ }
- // Look for local name conflict, prepend "::" as necessary.
- R.clear();
- S.LookupName(R, S.getCurScope());
-
- if (!FoundFunction) {
- if (!R.empty()) {
- AbsName = "::" + AbsName;
+ // Lookup all std::abs
+ if (NamespaceDecl *Std = S.getStdNamespace()) {
+ LookupResult R(S, &S.PP.getIdentifierTable().get("abs"), Loc,
+ Sema::LookupAnyName);
+ R.suppressDiagnostics();
+ S.LookupQualifiedName(R, Std);
+
+ for (const auto *I : R) {
+ const FunctionDecl *FDecl = 0;
+ if (const UsingShadowDecl *UsingD = dyn_cast<UsingShadowDecl>(I)) {
+ FDecl = dyn_cast<FunctionDecl>(UsingD->getTargetDecl());
+ } else {
+ FDecl = dyn_cast<FunctionDecl>(I);
+ }
+ if (!FDecl)
+ continue;
+
+ // Found std::abs(), check that they are the right ones.
+ if (FDecl->getNumParams() != 1)
+ continue;
+
+ // Check that the parameter type can handle the argument.
+ QualType ParamType = FDecl->getParamDecl(0)->getType();
+ if (getAbsoluteValueKind(ArgType) == getAbsoluteValueKind(ParamType) &&
+ S.Context.getTypeSize(ArgType) <=
+ S.Context.getTypeSize(ParamType)) {
+ // Found a function, don't need the header hint.
+ EmitHeaderHint = false;
+ break;
+ }
+ }
}
- } else { // FoundFunction
- if (R.isSingleResult()) {
- if (R.getFoundDecl() != FD) {
- AbsName = "::" + AbsName;
+ } else {
+ FunctionName = S.Context.BuiltinInfo.GetName(AbsKind);
+ HeaderName = S.Context.BuiltinInfo.getHeaderName(AbsKind);
+
+ if (HeaderName) {
+ DeclarationName DN(&S.Context.Idents.get(FunctionName));
+ LookupResult R(S, DN, Loc, Sema::LookupAnyName);
+ R.suppressDiagnostics();
+ S.LookupName(R, S.getCurScope());
+
+ if (R.isSingleResult()) {
+ FunctionDecl *FD = dyn_cast<FunctionDecl>(R.getFoundDecl());
+ if (FD && FD->getBuiltinID() == AbsKind) {
+ EmitHeaderHint = false;
+ } else {
+ return;
+ }
+ } else if (!R.empty()) {
+ return;
}
- } else if (!R.empty()) {
- AbsName = "::" + AbsName;
}
}
S.Diag(Loc, diag::note_replace_abs_function)
- << AbsName << FixItHint::CreateReplacement(Range, AbsName);
+ << FunctionName << FixItHint::CreateReplacement(Range, FunctionName);
- if (!FoundFunction) {
- S.Diag(Loc, diag::note_please_include_header)
- << S.Context.BuiltinInfo.getHeaderName(AbsKind)
- << S.Context.BuiltinInfo.GetName(AbsKind);
+ if (!HeaderName)
+ return;
+
+ if (!EmitHeaderHint)
+ return;
+
+ S.Diag(Loc, diag::note_please_include_header) << HeaderName << FunctionName;
+}
+
+static bool IsFunctionStdAbs(const FunctionDecl *FDecl) {
+ if (!FDecl)
+ return false;
+
+ if (!FDecl->getIdentifier() || !FDecl->getIdentifier()->isStr("abs"))
+ return false;
+
+ const NamespaceDecl *ND = dyn_cast<NamespaceDecl>(FDecl->getDeclContext());
+
+ while (ND && ND->isInlineNamespace()) {
+ ND = dyn_cast<NamespaceDecl>(ND->getDeclContext());
}
+
+ if (!ND || !ND->getIdentifier() || !ND->getIdentifier()->isStr("std"))
+ return false;
+
+ if (!isa<TranslationUnitDecl>(ND->getDeclContext()))
+ return false;
+
+ return true;
}
// Warn when using the wrong abs() function.
@@ -3920,7 +3973,8 @@ void Sema::CheckAbsoluteValueFunction(co
return;
unsigned AbsKind = getAbsoluteValueFunctionKind(FDecl);
- if (AbsKind == 0)
+ bool IsStdAbs = IsFunctionStdAbs(FDecl);
+ if (AbsKind == 0 && !IsStdAbs)
return;
QualType ArgType = Call->getArg(0)->IgnoreParenImpCasts()->getType();
@@ -3929,13 +3983,20 @@ void Sema::CheckAbsoluteValueFunction(co
// Unsigned types can not be negative. Suggest to drop the absolute value
// function.
if (ArgType->isUnsignedIntegerType()) {
+ const char *FunctionName =
+ IsStdAbs ? "std::abs" : Context.BuiltinInfo.GetName(AbsKind);
Diag(Call->getExprLoc(), diag::warn_unsigned_abs) << ArgType << ParamType;
Diag(Call->getExprLoc(), diag::note_remove_abs)
- << FDecl
+ << FunctionName
<< FixItHint::CreateRemoval(Call->getCallee()->getSourceRange());
return;
}
+ // std::abs has overloads which prevent most of the absolute value problems
+ // from occurring.
+ if (IsStdAbs)
+ return;
+
AbsoluteValueKind ArgValueKind = getAbsoluteValueKind(ArgType);
AbsoluteValueKind ParamValueKind = getAbsoluteValueKind(ParamType);
@@ -3953,7 +4014,7 @@ void Sema::CheckAbsoluteValueFunction(co
return;
emitReplacement(*this, Call->getExprLoc(),
- Call->getCallee()->getSourceRange(), NewAbsKind);
+ Call->getCallee()->getSourceRange(), NewAbsKind, ArgType);
return;
}
@@ -3969,7 +4030,7 @@ void Sema::CheckAbsoluteValueFunction(co
<< FDecl << ParamValueKind << ArgValueKind;
emitReplacement(*this, Call->getExprLoc(),
- Call->getCallee()->getSourceRange(), NewAbsKind);
+ Call->getCallee()->getSourceRange(), NewAbsKind, ArgType);
return;
}
Modified: cfe/trunk/test/SemaCXX/warn-absolute-value-header.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-absolute-value-header.cpp?rev=206340&r1=206339&r2=206340&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-absolute-value-header.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-absolute-value-header.cpp Tue Apr 15 18:47:53 2014
@@ -1,37 +1,53 @@
// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify %s -Wabsolute-value
// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only %s -Wabsolute-value -fdiagnostics-parseable-fixits 2>&1 | FileCheck %s
-extern "C" int abs(int);
+extern "C" {
+ int abs(int);
+ float fabsf(float);
+}
-// Wrong signature
-int fabsf(int);
+namespace std {
+ int abs(int);
+ float abs(float);
+}
-void test_int(int i, unsigned u, long long ll, float f, double d) {
- (void)abs(i);
+void test(long long ll, double d, int i, float f) {
+ // Suggest including cmath
+ (void)abs(d);
+ // expected-warning at -1{{using integer absolute value function 'abs' when argument is of floating point type}}
+ // expected-note at -2{{use function 'std::abs' instead}}
+ // expected-note at -3{{please include the header <cmath> or explicitly provide a declaration for 'std::abs'}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:12}:"std::abs"
+
+ (void)fabsf(d);
+ // expected-warning at -1{{absolute value function 'fabsf' given an argument of type 'double' but has parameter of type 'float' which may cause truncation of value}}
+ // expected-note at -2{{use function 'std::abs' instead}}
+ // expected-note at -3{{please include the header <cmath> or explicitly provide a declaration for 'std::abs'}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:14}:"std::abs"
- // Remove abs call
- (void)abs(u);
- // expected-warning at -1{{taking the absolute value of unsigned type 'unsigned int' has no effect}}
- // expected-note at -2{{remove the call to 'abs' since unsigned values cannot be negative}}
- // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:""
-
- int llabs;
- (void)llabs;
- // Conflict in names, suggest qualified name
+ // Suggest including cstdlib
(void)abs(ll);
// expected-warning at -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 at -2{{use function '::llabs' instead}}
- // expected-note at -3{{please include the header <stdlib.h> or explicitly provide a declaration for 'llabs'}}
- // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:12}:"::llabs"
+ // expected-note at -2{{use function 'std::abs' instead}}
+ // expected-note at -3{{please include the header <cstdlib> or explicitly provide a declaration for 'std::abs'}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:12}:"std::abs"
+ (void)fabsf(ll);
+ // expected-warning at -1{{using floating point absolute value function 'fabsf' when argument is of integer type}}
+ // expected-note at -2{{use function 'std::abs' instead}}
+ // expected-note at -3{{please include the header <cstdlib> or explicitly provide a declaration for 'std::abs'}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:14}:"std::abs"
- // Conflict in names, no notes
- (void)abs(f);
- // expected-warning at -1{{using integer absolute value function 'abs' when argument is of floating point type}}
+ // Proper function already called, no warnings.
+ (void)abs(i);
+ (void)fabsf(f);
- // Suggest header.
- (void)abs(d);
+ // Declarations found, suggest name change.
+ (void)fabsf(i);
+ // expected-warning at -1{{using floating point absolute value function 'fabsf' when argument is of integer type}}
+ // expected-note at -2{{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+ (void)abs(f);
// expected-warning at -1{{using integer absolute value function 'abs' when argument is of floating point type}}
- // expected-note at -2{{use function 'fabs' instead}}
- // expected-note at -3{{please include the header <math.h> or explicitly provide a declaration for 'fabs'}}
- // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:12}:"fabs"
+ // expected-note at -2{{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"std::abs"
}
Added: cfe/trunk/test/SemaCXX/warn-absolute-value.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-absolute-value.cpp?rev=206340&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-absolute-value.cpp (added)
+++ cfe/trunk/test/SemaCXX/warn-absolute-value.cpp Tue Apr 15 18:47:53 2014
@@ -0,0 +1,823 @@
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify %s -Wabsolute-value -std=c++11
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only %s -Wabsolute-value -fdiagnostics-parseable-fixits -std=c++11 2>&1 | FileCheck %s
+
+extern "C" {
+int abs(int);
+long int labs(long int);
+long long int llabs(long long int);
+
+float fabsf(float);
+double fabs(double);
+long double fabsl(long double);
+
+float cabsf(float _Complex);
+double cabs(double _Complex);
+long double cabsl(long double _Complex);
+}
+
+namespace std {
+
+inline namespace __1 {
+int abs(int);
+long int abs(long int);
+long long int abs(long long int);
+}
+
+float abs(float);
+double abs(double);
+long double abs(long double);
+
+template <typename T>
+double abs(T);
+
+}
+
+void test_int(int x) {
+ (void)std::abs(x);
+
+ (void)abs(x);
+ (void)labs(x);
+ (void)llabs(x);
+
+ (void)fabsf(x);
+ // expected-warning at -1 {{using floating point absolute value function 'fabsf' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+ (void)fabs(x);
+ // expected-warning at -1 {{using floating point absolute value function 'fabs' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
+ (void)fabsl(x);
+ // expected-warning at -1 {{using floating point absolute value function 'fabsl' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+
+ (void)cabsf(x);
+ // expected-warning at -1 {{using complex absolute value function 'cabsf' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+ (void)cabs(x);
+ // expected-warning at -1 {{using complex absolute value function 'cabs' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
+ (void)cabsl(x);
+ // expected-warning at -1 {{using complex absolute value function 'cabsl' when argument is of integer type}}
+ // expected-note at -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 at -1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+ (void)__builtin_fabs(x);
+ // expected-warning at -1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
+ (void)__builtin_fabsl(x);
+ // expected-warning at -1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+
+ (void)__builtin_cabsf(x);
+ // expected-warning at -1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+ (void)__builtin_cabs(x);
+ // expected-warning at -1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
+ (void)__builtin_cabsl(x);
+ // expected-warning at -1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+}
+
+void test_long(long x) {
+ (void)std::abs(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 at -1 {{using floating point absolute value function 'fabsf' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+ (void)fabs(x);
+ // expected-warning at -1 {{using floating point absolute value function 'fabs' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
+ (void)fabsl(x);
+ // expected-warning at -1 {{using floating point absolute value function 'fabsl' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+
+ (void)cabsf(x);
+ // expected-warning at -1 {{using complex absolute value function 'cabsf' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+ (void)cabs(x);
+ // expected-warning at -1 {{using complex absolute value function 'cabs' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
+ (void)cabsl(x);
+ // expected-warning at -1 {{using complex absolute value function 'cabsl' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+
+ (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 at -1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+ (void)__builtin_fabs(x);
+ // expected-warning at -1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
+ (void)__builtin_fabsl(x);
+ // expected-warning at -1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+
+ (void)__builtin_cabsf(x);
+ // expected-warning at -1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+ (void)__builtin_cabs(x);
+ // expected-warning at -1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
+ (void)__builtin_cabsl(x);
+ // expected-warning at -1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+}
+
+void test_long_long(long long x) {
+ (void)std::abs(x);
+
+ (void)abs(x);
+ // expected-warning at -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 at -2{{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"std::abs"
+ (void)labs(x);
+ // expected-warning at -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 at -2{{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
+ (void)llabs(x);
+
+ (void)fabsf(x);
+ // expected-warning at -1 {{using floating point absolute value function 'fabsf' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+ (void)fabs(x);
+ // expected-warning at -1 {{using floating point absolute value function 'fabs' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
+ (void)fabsl(x);
+ // expected-warning at -1 {{using floating point absolute value function 'fabsl' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+
+ (void)cabsf(x);
+ // expected-warning at -1 {{using complex absolute value function 'cabsf' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+ (void)cabs(x);
+ // expected-warning at -1 {{using complex absolute value function 'cabs' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
+ (void)cabsl(x);
+ // expected-warning at -1 {{using complex absolute value function 'cabsl' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+
+ (void)__builtin_abs(x);
+ // expected-warning at -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 at -2{{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"std::abs"
+ (void)__builtin_labs(x);
+ // expected-warning at -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 at -2{{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
+ (void)__builtin_llabs(x);
+
+ (void)__builtin_fabsf(x);
+ // expected-warning at -1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+ (void)__builtin_fabs(x);
+ // expected-warning at -1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
+ (void)__builtin_fabsl(x);
+ // expected-warning at -1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+
+ (void)__builtin_cabsf(x);
+ // expected-warning at -1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+ (void)__builtin_cabs(x);
+ // expected-warning at -1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
+ (void)__builtin_cabsl(x);
+ // expected-warning at -1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+}
+
+void test_float(float x) {
+ (void)std::abs(x);
+
+ (void)abs(x);
+ // expected-warning at -1 {{using integer absolute value function 'abs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"std::abs"
+ (void)labs(x);
+ // expected-warning at -1 {{using integer absolute value function 'labs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
+ (void)llabs(x);
+ // expected-warning at -1 {{using integer absolute value function 'llabs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+
+ (void)fabsf(x);
+ (void)fabs(x);
+ (void)fabsl(x);
+
+ (void)cabsf(x);
+ // expected-warning at -1 {{using complex absolute value function 'cabsf' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+ (void)cabs(x);
+ // expected-warning at -1 {{using complex absolute value function 'cabs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
+ (void)cabsl(x);
+ // expected-warning at -1 {{using complex absolute value function 'cabsl' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+
+ (void)__builtin_abs(x);
+ // expected-warning at -1 {{using integer absolute value function '__builtin_abs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"std::abs"
+ (void)__builtin_labs(x);
+ // expected-warning at -1 {{using integer absolute value function '__builtin_labs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
+ (void)__builtin_llabs(x);
+ // expected-warning at -1 {{using integer absolute value function '__builtin_llabs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+
+ (void)__builtin_fabsf(x);
+ (void)__builtin_fabs(x);
+ (void)__builtin_fabsl(x);
+
+ (void)__builtin_cabsf(x);
+ // expected-warning at -1 {{using complex absolute value function '__builtin_cabsf' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+ (void)__builtin_cabs(x);
+ // expected-warning at -1 {{using complex absolute value function '__builtin_cabs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
+ (void)__builtin_cabsl(x);
+ // expected-warning at -1 {{using complex absolute value function '__builtin_cabsl' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+}
+
+void test_double(double x) {
+ (void)std::abs(x);
+
+ (void)abs(x);
+ // expected-warning at -1 {{using integer absolute value function 'abs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"std::abs"
+ (void)labs(x);
+ // expected-warning at -1 {{using integer absolute value function 'labs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
+ (void)llabs(x);
+ // expected-warning at -1 {{using integer absolute value function 'llabs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+
+ (void)fabsf(x);
+ // expected-warning at -1{{absolute value function 'fabsf' given an argument of type 'double' but has parameter of type 'float' which may cause truncation of value}}
+ // expected-note at -2{{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+ (void)fabs(x);
+ (void)fabsl(x);
+
+ (void)cabsf(x);
+ // expected-warning at -1 {{using complex absolute value function 'cabsf' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+ (void)cabs(x);
+ // expected-warning at -1 {{using complex absolute value function 'cabs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
+ (void)cabsl(x);
+ // expected-warning at -1 {{using complex absolute value function 'cabsl' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+
+ (void)__builtin_abs(x);
+ // expected-warning at -1 {{using integer absolute value function '__builtin_abs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"std::abs"
+ (void)__builtin_labs(x);
+ // expected-warning at -1 {{using integer absolute value function '__builtin_labs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
+ (void)__builtin_llabs(x);
+ // expected-warning at -1 {{using integer absolute value function '__builtin_llabs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+
+ (void)__builtin_fabsf(x);
+ // expected-warning at -1{{absolute value function '__builtin_fabsf' given an argument of type 'double' but has parameter of type 'float' which may cause truncation of value}}
+ // expected-note at -2{{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+ (void)__builtin_fabs(x);
+ (void)__builtin_fabsl(x);
+
+ (void)__builtin_cabsf(x);
+ // expected-warning at -1 {{using complex absolute value function '__builtin_cabsf' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+ (void)__builtin_cabs(x);
+ // expected-warning at -1 {{using complex absolute value function '__builtin_cabs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
+ (void)__builtin_cabsl(x);
+ // expected-warning at -1 {{using complex absolute value function '__builtin_cabsl' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+}
+
+void test_long_double(long double x) {
+ (void)std::abs(x);
+
+ (void)abs(x);
+ // expected-warning at -1 {{using integer absolute value function 'abs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"std::abs"
+ (void)labs(x);
+ // expected-warning at -1 {{using integer absolute value function 'labs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
+ (void)llabs(x);
+ // expected-warning at -1 {{using integer absolute value function 'llabs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+
+ (void)fabsf(x);
+ // expected-warning at -1{{absolute value function 'fabsf' given an argument of type 'long double' but has parameter of type 'float' which may cause truncation of value}}
+ // expected-note at -2{{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+ (void)fabs(x);
+ // expected-warning at -1{{absolute value function 'fabs' given an argument of type 'long double' but has parameter of type 'double' which may cause truncation of value}}
+ // expected-note at -2{{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
+ (void)fabsl(x);
+
+ (void)cabsf(x);
+ // expected-warning at -1 {{using complex absolute value function 'cabsf' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+ (void)cabs(x);
+ // expected-warning at -1 {{using complex absolute value function 'cabs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
+ (void)cabsl(x);
+ // expected-warning at -1 {{using complex absolute value function 'cabsl' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
+
+ (void)__builtin_abs(x);
+ // expected-warning at -1 {{using integer absolute value function '__builtin_abs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"std::abs"
+ (void)__builtin_labs(x);
+ // expected-warning at -1 {{using integer absolute value function '__builtin_labs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
+ (void)__builtin_llabs(x);
+ // expected-warning at -1 {{using integer absolute value function '__builtin_llabs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+
+ (void)__builtin_fabsf(x);
+ // expected-warning at -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}}
+ // expected-note at -2{{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+ (void)__builtin_fabs(x);
+ // expected-warning at -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}}
+ // expected-note at -2{{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
+ (void)__builtin_fabsl(x);
+
+ (void)__builtin_cabsf(x);
+ // expected-warning at -1 {{using complex absolute value function '__builtin_cabsf' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+ (void)__builtin_cabs(x);
+ // expected-warning at -1 {{using complex absolute value function '__builtin_cabs' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
+ (void)__builtin_cabsl(x);
+ // expected-warning at -1 {{using complex absolute value function '__builtin_cabsl' when argument is of floating point type}}
+ // expected-note at -2 {{use function 'std::abs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
+}
+
+void test_complex_float(_Complex float x) {
+ (void)abs(x);
+ // expected-warning at -1 {{using integer absolute value function 'abs' when argument is of complex type}}
+ // expected-note at -2 {{use function 'cabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabsf"
+ (void)labs(x);
+ // expected-warning at -1 {{using integer absolute value function 'labs' when argument is of complex type}}
+ // expected-note at -2 {{use function 'cabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsf"
+ (void)llabs(x);
+ // expected-warning at -1 {{using integer absolute value function 'llabs' when argument is of complex type}}
+ // expected-note at -2 {{use function 'cabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf"
+
+ (void)fabsf(x);
+ // expected-warning at -1 {{using floating point absolute value function 'fabsf' when argument is of complex type}}
+ // expected-note at -2 {{use function 'cabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf"
+ (void)fabs(x);
+ // expected-warning at -1 {{using floating point absolute value function 'fabs' when argument is of complex type}}
+ // expected-note at -2 {{use function 'cabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsf"
+ (void)fabsl(x);
+ // expected-warning at -1 {{using floating point absolute value function 'fabsl' when argument is of complex type}}
+ // expected-note at -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 at -1 {{using integer absolute value function '__builtin_abs' when argument is of complex type}}
+ // expected-note at -2 {{use function '__builtin_cabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_cabsf"
+ (void)__builtin_labs(x);
+ // expected-warning at -1 {{using integer absolute value function '__builtin_labs' when argument is of complex type}}
+ // expected-note at -2 {{use function '__builtin_cabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsf"
+ (void)__builtin_llabs(x);
+ // expected-warning at -1 {{using integer absolute value function '__builtin_llabs' when argument is of complex type}}
+ // expected-note at -2 {{use function '__builtin_cabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf"
+
+ (void)__builtin_fabsf(x);
+ // expected-warning at -1 {{using floating point absolute value function '__builtin_fabsf' when argument is of complex type}}
+ // expected-note at -2 {{use function '__builtin_cabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf"
+ (void)__builtin_fabs(x);
+ // expected-warning at -1 {{using floating point absolute value function '__builtin_fabs' when argument is of complex type}}
+ // expected-note at -2 {{use function '__builtin_cabsf' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsf"
+ (void)__builtin_fabsl(x);
+ // expected-warning at -1 {{using floating point absolute value function '__builtin_fabsl' when argument is of complex type}}
+ // expected-note at -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_complex_double(_Complex double x) {
+ (void)abs(x);
+ // expected-warning at -1 {{using integer absolute value function 'abs' when argument is of complex type}}
+ // expected-note at -2 {{use function 'cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabs"
+ (void)labs(x);
+ // expected-warning at -1 {{using integer absolute value function 'labs' when argument is of complex type}}
+ // expected-note at -2 {{use function 'cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabs"
+ (void)llabs(x);
+ // expected-warning at -1 {{using integer absolute value function 'llabs' when argument is of complex type}}
+ // expected-note at -2 {{use function 'cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs"
+
+ (void)fabsf(x);
+ // expected-warning at -1 {{using floating point absolute value function 'fabsf' when argument is of complex type}}
+ // expected-note at -2 {{use function 'cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs"
+ (void)fabs(x);
+ // expected-warning at -1 {{using floating point absolute value function 'fabs' when argument is of complex type}}
+ // expected-note at -2 {{use function 'cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabs"
+ (void)fabsl(x);
+ // expected-warning at -1 {{using floating point absolute value function 'fabsl' when argument is of complex type}}
+ // expected-note at -2 {{use function 'cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs"
+
+ (void)cabsf(x);
+ // expected-warning at -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}}
+ // expected-note at -2 {{use function 'cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs"
+ (void)cabs(x);
+ (void)cabsl(x);
+
+ (void)__builtin_abs(x);
+ // expected-warning at -1 {{using integer absolute value function '__builtin_abs' when argument is of complex type}}
+ // expected-note at -2 {{use function '__builtin_cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_cabs"
+ (void)__builtin_labs(x);
+ // expected-warning at -1 {{using integer absolute value function '__builtin_labs' when argument is of complex type}}
+ // expected-note at -2 {{use function '__builtin_cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabs"
+ (void)__builtin_llabs(x);
+ // expected-warning at -1 {{using integer absolute value function '__builtin_llabs' when argument is of complex type}}
+ // expected-note at -2 {{use function '__builtin_cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs"
+
+ (void)__builtin_fabsf(x);
+ // expected-warning at -1 {{using floating point absolute value function '__builtin_fabsf' when argument is of complex type}}
+ // expected-note at -2 {{use function '__builtin_cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs"
+ (void)__builtin_fabs(x);
+ // expected-warning at -1 {{using floating point absolute value function '__builtin_fabs' when argument is of complex type}}
+ // expected-note at -2 {{use function '__builtin_cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabs"
+ (void)__builtin_fabsl(x);
+ // expected-warning at -1 {{using floating point absolute value function '__builtin_fabsl' when argument is of complex type}}
+ // expected-note at -2 {{use function '__builtin_cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs"
+
+ (void)__builtin_cabsf(x);
+ // expected-warning at -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}}
+ // expected-note at -2 {{use function '__builtin_cabs' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs"
+ (void)__builtin_cabs(x);
+ (void)__builtin_cabsl(x);
+}
+
+void test_complex_long_double(_Complex long double x) {
+ (void)abs(x);
+ // expected-warning at -1 {{using integer absolute value function 'abs' when argument is of complex type}}
+ // expected-note at -2 {{use function 'cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabsl"
+ (void)labs(x);
+ // expected-warning at -1 {{using integer absolute value function 'labs' when argument is of complex type}}
+ // expected-note at -2 {{use function 'cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl"
+ (void)llabs(x);
+ // expected-warning at -1 {{using integer absolute value function 'llabs' when argument is of complex type}}
+ // expected-note at -2 {{use function 'cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"
+
+ (void)fabsf(x);
+ // expected-warning at -1 {{using floating point absolute value function 'fabsf' when argument is of complex type}}
+ // expected-note at -2 {{use function 'cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"
+ (void)fabs(x);
+ // expected-warning at -1 {{using floating point absolute value function 'fabs' when argument is of complex type}}
+ // expected-note at -2 {{use function 'cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl"
+ (void)fabsl(x);
+ // expected-warning at -1 {{using floating point absolute value function 'fabsl' when argument is of complex type}}
+ // expected-note at -2 {{use function 'cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"
+
+ (void)cabsf(x);
+ // expected-warning at -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 at -2 {{use function 'cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"
+ (void)cabs(x);
+ // expected-warning at -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 at -2 {{use function 'cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl"
+ (void)cabsl(x);
+
+ (void)__builtin_abs(x);
+ // expected-warning at -1 {{using integer absolute value function '__builtin_abs' when argument is of complex type}}
+ // expected-note at -2 {{use function '__builtin_cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_cabsl"
+ (void)__builtin_labs(x);
+ // expected-warning at -1 {{using integer absolute value function '__builtin_labs' when argument is of complex type}}
+ // expected-note at -2 {{use function '__builtin_cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl"
+ (void)__builtin_llabs(x);
+ // expected-warning at -1 {{using integer absolute value function '__builtin_llabs' when argument is of complex type}}
+ // expected-note at -2 {{use function '__builtin_cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl"
+
+ (void)__builtin_fabsf(x);
+ // expected-warning at -1 {{using floating point absolute value function '__builtin_fabsf' when argument is of complex type}}
+ // expected-note at -2 {{use function '__builtin_cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl"
+ (void)__builtin_fabs(x);
+ // expected-warning at -1 {{using floating point absolute value function '__builtin_fabs' when argument is of complex type}}
+ // expected-note at -2 {{use function '__builtin_cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl"
+ (void)__builtin_fabsl(x);
+ // expected-warning at -1 {{using floating point absolute value function '__builtin_fabsl' when argument is of complex type}}
+ // expected-note at -2 {{use function '__builtin_cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl"
+
+ (void)__builtin_cabsf(x);
+ // expected-warning at -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 at -2 {{use function '__builtin_cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl"
+ (void)__builtin_cabs(x);
+ // expected-warning at -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 at -2 {{use function '__builtin_cabsl' instead}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl"
+ (void)__builtin_cabsl(x);
+}
+
+void test_unsigned_int(unsigned int x) {
+ (void)std::abs(x);
+ // expected-warning at -1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note at -2 {{remove the call to 'std::abs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:17}:""
+
+ (void)abs(x);
+ // expected-warning at -1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
+ // expected-note at -2 {{remove the call to '__builtin_cabsl' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
+}
+
+void test_unsigned_long(unsigned long x) {
+ (void)std::abs(x);
+ // expected-warning at -1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note at -2 {{remove the call to 'std::abs' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:17}:""
+
+ (void)abs(x);
+ // expected-warning at -1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note at -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 at -1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
+ // expected-note at -2 {{remove the call to '__builtin_cabsl' since unsigned values cannot be negative}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
+}
+
Removed: cfe/trunk/test/SemaCXX/warn-absolute-value2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-absolute-value2.cpp?rev=206339&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-absolute-value2.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-absolute-value2.cpp (removed)
@@ -1,13 +0,0 @@
-// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify %s -Wabsolute-value
-
-extern "C" {
-int abs(int);
-double fabs(double);
-}
-
-using ::fabs;
-
-double test(double x) {
- return ::abs(x);
- // expected-warning at -1{{using integer absolute value function 'abs' when argument is of floating point type}}
-}
More information about the cfe-commits
mailing list