diff options
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticGroups.td | 1 | ||||
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 15 | ||||
| -rw-r--r-- | clang/include/clang/Sema/Sema.h | 4 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 325 | ||||
| -rw-r--r-- | clang/test/Sema/warn-absolute-value-header.c | 36 | ||||
| -rw-r--r-- | clang/test/Sema/warn-absolute-value.c | 782 | ||||
| -rw-r--r-- | clang/test/SemaCXX/warn-absolute-value-header.cpp | 37 |
7 files changed, 1200 insertions, 0 deletions
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 5d527ab9e8a..d80b4931dc8 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -18,6 +18,7 @@ def Implicit : DiagGroup<"implicit", [ // Empty DiagGroups are recognized by clang but ignored. def : DiagGroup<"abi">; +def AbsoluteValue : DiagGroup<"absolute-value">; def : DiagGroup<"address">; def AddressOfTemporary : DiagGroup<"address-of-temporary">; def : DiagGroup<"aggregate-return">; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index aaebf59d8aa..41d683fcb88 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -30,6 +30,21 @@ def warn_duplicate_enum_values : Warning< "been assigned">, InGroup<DiagGroup<"duplicate-enum">>, DefaultIgnore; def note_duplicate_element : Note<"element %0 also has value %1">; +// Absolute value functions +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">; +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>; +def warn_wrong_absolute_value_type : Warning< + "using %select{integer|floating point|complex}1 absolute value function %0 " + "when argument is of %select{integer|floating point|complex}2 type">, + InGroup<AbsoluteValue>; +def note_replace_abs_function : Note<"use function '%0' instead">; + def warn_infinite_recursive_function : Warning< "all paths through this function will call itself">, InGroup<InfiniteRecursion>, DefaultIgnore; diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 54f71620d57..3659214ec63 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -7941,6 +7941,10 @@ private: SourceLocation Loc, SourceRange range, llvm::SmallBitVector &CheckedVarArgs); + void CheckAbsoluteValueFunction(const CallExpr *Call, + const FunctionDecl *FDecl, + IdentifierInfo *FnInfo); + void CheckMemaccessArguments(const CallExpr *Call, unsigned BId, IdentifierInfo *FnName); diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index c978a1e5b11..936399ed969 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -851,6 +851,8 @@ bool Sema::CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall, if (!FnInfo) return false; + CheckAbsoluteValueFunction(TheCall, FDecl, FnInfo); + unsigned CMId = FDecl->getMemoryFunctionKind(); if (CMId == 0) return false; @@ -3582,6 +3584,328 @@ void Sema::CheckFormatString(const StringLiteral *FExpr, } // TODO: handle other formats } +//===--- CHECK: Warn on use of wrong absolute value function. -------------===// + +// Returns the related absolute value function that is larger, of 0 if one +// does not exist. +static unsigned getLargerAbsoluteValueFunction(unsigned AbsFunction) { + switch (AbsFunction) { + default: + return 0; + + case Builtin::BI__builtin_abs: + return Builtin::BI__builtin_labs; + case Builtin::BI__builtin_labs: + return Builtin::BI__builtin_llabs; + case Builtin::BI__builtin_llabs: + return 0; + + case Builtin::BI__builtin_fabsf: + return Builtin::BI__builtin_fabs; + case Builtin::BI__builtin_fabs: + return Builtin::BI__builtin_fabsl; + case Builtin::BI__builtin_fabsl: + return 0; + + case Builtin::BI__builtin_cabsf: + return Builtin::BI__builtin_cabs; + case Builtin::BI__builtin_cabs: + return Builtin::BI__builtin_cabsl; + case Builtin::BI__builtin_cabsl: + return 0; + + case Builtin::BIabs: + return Builtin::BIlabs; + case Builtin::BIlabs: + return Builtin::BIllabs; + case Builtin::BIllabs: + return 0; + + case Builtin::BIfabsf: + return Builtin::BIfabs; + case Builtin::BIfabs: + return Builtin::BIfabsl; + case Builtin::BIfabsl: + return 0; + + case Builtin::BIcabsf: + return Builtin::BIcabs; + case Builtin::BIcabs: + return Builtin::BIcabsl; + case Builtin::BIcabsl: + return 0; + } +} + +// Returns the argument type of the absolute value function. +static QualType getAbsoluteValueArgumentType(ASTContext &Context, + unsigned AbsType) { + if (AbsType == 0) + return QualType(); + + ASTContext::GetBuiltinTypeError Error = ASTContext::GE_None; + QualType BuiltinType = Context.GetBuiltinType(AbsType, Error); + if (Error != ASTContext::GE_None) + return QualType(); + + const FunctionProtoType *FT = BuiltinType->getAs<FunctionProtoType>(); + if (!FT) + return QualType(); + + if (FT->getNumParams() != 1) + return QualType(); + + return FT->getParamType(0); +} + +// Returns the best absolute value function, or zero, based on type and +// current absolute value function. +static unsigned getBestAbsFunction(ASTContext &Context, QualType ArgType, + unsigned AbsFunctionKind) { + unsigned BestKind = 0; + uint64_t ArgSize = Context.getTypeSize(ArgType); + for (unsigned Kind = AbsFunctionKind; Kind != 0; + Kind = getLargerAbsoluteValueFunction(Kind)) { + QualType ParamType = getAbsoluteValueArgumentType(Context, Kind); + if (Context.getTypeSize(ParamType) >= ArgSize) { + if (BestKind == 0) + BestKind = Kind; + else if (Context.hasSameType(ParamType, ArgType)) { + BestKind = Kind; + break; + } + } + } + return BestKind; +} + +enum AbsoluteValueKind { + AVK_Integer, + AVK_Floating, + AVK_Complex +}; + +static AbsoluteValueKind getAbsoluteValueKind(QualType T) { + if (T->isIntegralOrEnumerationType()) + return AVK_Integer; + if (T->isRealFloatingType()) + return AVK_Floating; + if (T->isAnyComplexType()) + return AVK_Complex; + + llvm_unreachable("Type not integer, floating, or complex"); +} + +// Changes the absolute value function to a different type. Preserves whether +// the function is a builtin. +static unsigned changeAbsFunction(unsigned AbsKind, + AbsoluteValueKind ValueKind) { + switch (ValueKind) { + case AVK_Integer: + switch (AbsKind) { + default: + return 0; + case Builtin::BI__builtin_fabsf: + case Builtin::BI__builtin_fabs: + case Builtin::BI__builtin_fabsl: + case Builtin::BI__builtin_cabsf: + case Builtin::BI__builtin_cabs: + case Builtin::BI__builtin_cabsl: + return Builtin::BI__builtin_abs; + case Builtin::BIfabsf: + case Builtin::BIfabs: + case Builtin::BIfabsl: + case Builtin::BIcabsf: + case Builtin::BIcabs: + case Builtin::BIcabsl: + return Builtin::BIabs; + } + case AVK_Floating: + switch (AbsKind) { + default: + return 0; + case Builtin::BI__builtin_abs: + case Builtin::BI__builtin_labs: + case Builtin::BI__builtin_llabs: + case Builtin::BI__builtin_cabsf: + case Builtin::BI__builtin_cabs: + case Builtin::BI__builtin_cabsl: + return Builtin::BI__builtin_fabsf; + case Builtin::BIabs: + case Builtin::BIlabs: + case Builtin::BIllabs: + case Builtin::BIcabsf: + case Builtin::BIcabs: + case Builtin::BIcabsl: + return Builtin::BIfabsf; + } + case AVK_Complex: + switch (AbsKind) { + default: + return 0; + case Builtin::BI__builtin_abs: + case Builtin::BI__builtin_labs: + case Builtin::BI__builtin_llabs: + case Builtin::BI__builtin_fabsf: + case Builtin::BI__builtin_fabs: + case Builtin::BI__builtin_fabsl: + return Builtin::BI__builtin_cabsf; + case Builtin::BIabs: + case Builtin::BIlabs: + case Builtin::BIllabs: + case Builtin::BIfabsf: + case Builtin::BIfabs: + case Builtin::BIfabsl: + return Builtin::BIcabsf; + } + } + llvm_unreachable("Unable to convert function"); +} + +unsigned getAbsoluteValueFunctionKind(const FunctionDecl *FDecl) { + const IdentifierInfo *FnInfo = FDecl->getIdentifier(); + if (!FnInfo) + return 0; + + switch (FDecl->getBuiltinID()) { + default: + return 0; + case Builtin::BI__builtin_abs: + case Builtin::BI__builtin_fabs: + case Builtin::BI__builtin_fabsf: + case Builtin::BI__builtin_fabsl: + case Builtin::BI__builtin_labs: + case Builtin::BI__builtin_llabs: + case Builtin::BI__builtin_cabs: + case Builtin::BI__builtin_cabsf: + case Builtin::BI__builtin_cabsl: + case Builtin::BIabs: + case Builtin::BIlabs: + case Builtin::BIllabs: + case Builtin::BIfabs: + case Builtin::BIfabsf: + case Builtin::BIfabsl: + case Builtin::BIcabs: + case Builtin::BIcabsf: + case Builtin::BIcabsl: + return FDecl->getBuiltinID(); + } + llvm_unreachable("Unknown Builtin type"); +} + +// 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); + 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; + } + + // Look for local name conflict, prepend "::" as necessary. + R.clear(); + S.LookupName(R, S.getCurScope()); + + if (!FoundFunction) { + if (!R.empty()) { + AbsName = "::" + AbsName; + } + } else { // FoundFunction + if (R.isSingleResult()) { + if (R.getFoundDecl() != FD) { + AbsName = "::" + AbsName; + } + } else if (!R.empty()) { + AbsName = "::" + AbsName; + } + } + + S.Diag(Loc, diag::note_replace_abs_function) + << AbsName << FixItHint::CreateReplacement(Range, AbsName); + + if (!FoundFunction) { + S.Diag(Loc, diag::note_please_include_header) + << S.Context.BuiltinInfo.getHeaderName(AbsKind) + << S.Context.BuiltinInfo.GetName(AbsKind); + } +} + +// Warn when using the wrong abs() function. +void Sema::CheckAbsoluteValueFunction(const CallExpr *Call, + const FunctionDecl *FDecl, + IdentifierInfo *FnInfo) { + if (Call->getNumArgs() != 1) + return; + + unsigned AbsKind = getAbsoluteValueFunctionKind(FDecl); + if (AbsKind == 0) + return; + + QualType ArgType = Call->getArg(0)->IgnoreParenImpCasts()->getType(); + QualType ParamType = Call->getArg(0)->getType(); + + // Unsigned types can not be negative. Suggest to drop the absolute value + // function. + if (ArgType->isUnsignedIntegerType()) { + Diag(Call->getExprLoc(), diag::warn_unsigned_abs) << ArgType << ParamType; + Diag(Call->getExprLoc(), diag::note_remove_abs) + << FDecl + << FixItHint::CreateRemoval(Call->getCallee()->getSourceRange()); + return; + } + + AbsoluteValueKind ArgValueKind = getAbsoluteValueKind(ArgType); + AbsoluteValueKind ParamValueKind = getAbsoluteValueKind(ParamType); + + // The argument and parameter are the same kind. Check if they are the right + // size. + if (ArgValueKind == ParamValueKind) { + if (Context.getTypeSize(ArgType) <= Context.getTypeSize(ParamType)) + return; + + unsigned NewAbsKind = getBestAbsFunction(Context, ArgType, AbsKind); + Diag(Call->getExprLoc(), diag::warn_abs_too_small) + << FDecl << ArgType << ParamType; + + if (NewAbsKind == 0) + return; + + emitReplacement(*this, Call->getExprLoc(), + Call->getCallee()->getSourceRange(), NewAbsKind); + return; + } + + // ArgValueKind != ParamValueKind + // The wrong type of absolute value function was used. Attempt to find the + // proper one. + unsigned NewAbsKind = changeAbsFunction(AbsKind, ArgValueKind); + NewAbsKind = getBestAbsFunction(Context, ArgType, NewAbsKind); + if (NewAbsKind == 0) + return; + + Diag(Call->getExprLoc(), diag::warn_wrong_absolute_value_type) + << FDecl << ParamValueKind << ArgValueKind; + + emitReplacement(*this, Call->getExprLoc(), + Call->getCallee()->getSourceRange(), NewAbsKind); + return; +} + //===--- CHECK: Standard memory functions ---------------------------------===// /// \brief Takes the expression passed to the size_t parameter of functions @@ -7518,3 +7842,4 @@ void Sema::CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr, << ArgumentExpr->getSourceRange() << TypeTagExpr->getSourceRange(); } + diff --git a/clang/test/Sema/warn-absolute-value-header.c b/clang/test/Sema/warn-absolute-value-header.c new file mode 100644 index 00000000000..e3bf9ee1e65 --- /dev/null +++ b/clang/test/Sema/warn-absolute-value-header.c @@ -0,0 +1,36 @@ +// 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 + +int abs(int); + +// Wrong signature +int fabsf(int); +// expected-warning@-1{{incompatible redeclaration of library function 'fabsf'}} +// expected-note@-2{{'fabsf' is a builtin with type 'float (float)'}} + +void test_int(int i, unsigned u, long long ll, float f, double d) { + (void)abs(i); + + // Remove abs call + (void)abs(u); + // expected-warning@-1{{taking the absolute value of unsigned type 'unsigned int' 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}:"" + + int llabs; + (void)llabs; + // Conflict in names, no notes + (void)abs(ll); + // 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}} + + // Conflict in names, no notes + (void)abs(f); + // expected-warning@-1{{using integer absolute value function 'abs' when argument is of floating point type}} + + // Suggest header. + (void)abs(d); + // expected-warning@-1{{using integer absolute value function 'abs' when argument is of floating point type}} + // expected-note@-2{{use function 'fabs' instead}} + // expected-note@-3{{please include the header <math.h> or explicitly provide a declaration for 'fabs'}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:12}:"fabs" +} diff --git a/clang/test/Sema/warn-absolute-value.c b/clang/test/Sema/warn-absolute-value.c new file mode 100644 index 00000000000..70601db63a1 --- /dev/null +++ b/clang/test/Sema/warn-absolute-value.c @@ -0,0 +1,782 @@ +// 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 + +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); + +void test_int(int 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 'abs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"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 'abs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"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 'abs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"abs" + + (void)cabsf(x); + // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}} + // expected-note@-2 {{use function 'abs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"abs" + (void)cabs(x); + // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}} + // expected-note@-2 {{use function 'abs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"abs" + (void)cabsl(x); + // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}} + // expected-note@-2 {{use function 'abs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"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 '__builtin_abs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_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 '__builtin_abs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_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 '__builtin_abs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_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 '__builtin_abs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_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 '__builtin_abs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_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 '__builtin_abs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_abs" +} + +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_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_float(float x) { + (void)abs(x); + // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of floating point type}} + // expected-note@-2 {{use function 'fabsf' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"fabsf" + (void)labs(x); + // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of floating point type}} + // expected-note@-2 {{use function 'fabsf' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabsf" + (void)llabs(x); + // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of floating point type}} + // expected-note@-2 {{use function 'fabsf' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsf" + + (void)fabsf(x); + (void)fabs(x); + (void)fabsl(x); + + (void)cabsf(x); + // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of floating point type}} + // expected-note@-2 {{use function 'fabsf' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsf" + (void)cabs(x); + // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of floating point type}} + // expected-note@-2 {{use function 'fabsf' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabsf" + (void)cabsl(x); + // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of floating point type}} + // expected-note@-2 {{use function 'fabsf' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsf" + + (void)__builtin_abs(x); + // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of floating point type}} + // expected-note@-2 {{use function '__builtin_fabsf' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_fabsf" + (void)__builtin_labs(x); + // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of floating point type}} + // expected-note@-2 {{use function '__builtin_fabsf' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabsf" + (void)__builtin_llabs(x); + // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of floating point type}} + // expected-note@-2 {{use function '__builtin_fabsf' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsf" + + (void)__builtin_fabsf(x); + (void)__builtin_fabs(x); + (void)__builtin_fabsl(x); + + (void)__builtin_cabsf(x); + // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of floating point type}} + // expected-note@-2 {{use function '__builtin_fabsf' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsf" + (void)__builtin_cabs(x); + // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of floating point type}} + // expected-note@-2 {{use function '__builtin_fabsf' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabsf" + (void)__builtin_cabsl(x); + // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of floating point type}} + // expected-note@-2 {{use function '__builtin_fabsf' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsf" +} + +void test_double(double x) { + (void)abs(x); + // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of floating point type}} + // expected-note@-2 {{use function 'fabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"fabs" + (void)labs(x); + // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of floating point type}} + // expected-note@-2 {{use function 'fabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabs" + (void)llabs(x); + // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of floating point type}} + // expected-note@-2 {{use function 'fabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabs" + + (void)fabsf(x); + // 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}} + // expected-note@-2{{use function 'fabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabs" + (void)fabs(x); + (void)fabsl(x); + + (void)cabsf(x); + // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of floating point type}} + // expected-note@-2 {{use function 'fabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabs" + (void)cabs(x); + // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of floating point type}} + // expected-note@-2 {{use function 'fabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabs" + (void)cabsl(x); + // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of floating point type}} + // expected-note@-2 {{use function 'fabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabs" + + (void)__builtin_abs(x); + // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of floating point type}} + // expected-note@-2 {{use function '__builtin_fabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_fabs" + (void)__builtin_labs(x); + // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of floating point type}} + // expected-note@-2 {{use function '__builtin_fabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabs" + (void)__builtin_llabs(x); + // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of floating point type}} + // expected-note@-2 {{use function '__builtin_fabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabs" + + (void)__builtin_fabsf(x); + // 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}} + // expected-note@-2{{use function '__builtin_fabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabs" + (void)__builtin_fabs(x); + (void)__builtin_fabsl(x); + + (void)__builtin_cabsf(x); + // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of floating point type}} + // expected-note@-2 {{use function '__builtin_fabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabs" + (void)__builtin_cabs(x); + // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of floating point type}} + // expected-note@-2 {{use function '__builtin_fabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabs" + (void)__builtin_cabsl(x); + // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of floating point type}} + // expected-note@-2 {{use function '__builtin_fabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabs" +} + +void test_long_double(long double x) { + (void)abs(x); + // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of floating point type}} + // expected-note@-2 {{use function 'fabsl' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"fabsl" + (void)labs(x); + // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of floating point type}} + // expected-note@-2 {{use function 'fabsl' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabsl" + (void)llabs(x); + // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of floating point type}} + // expected-note@-2 {{use function 'fabsl' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsl" + + (void)fabsf(x); + // 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}} + // expected-note@-2{{use function 'fabsl' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsl" + (void)fabs(x); + // 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}} + // expected-note@-2{{use function 'fabsl' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabsl" + (void)fabsl(x); + + (void)cabsf(x); + // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of floating point type}} + // expected-note@-2 {{use function 'fabsl' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsl" + (void)cabs(x); + // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of floating point type}} + // expected-note@-2 {{use function 'fabsl' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabsl" + (void)cabsl(x); + // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of floating point type}} + // expected-note@-2 {{use function 'fabsl' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsl" + + (void)__builtin_abs(x); + // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of floating point type}} + // expected-note@-2 {{use function '__builtin_fabsl' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_fabsl" + (void)__builtin_labs(x); + // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of floating point type}} + // expected-note@-2 {{use function '__builtin_fabsl' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabsl" + (void)__builtin_llabs(x); + // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of floating point type}} + // expected-note@-2 {{use function '__builtin_fabsl' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsl" + + (void)__builtin_fabsf(x); + // 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}} + // expected-note@-2{{use function '__builtin_fabsl' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsl" + (void)__builtin_fabs(x); + // 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}} + // expected-note@-2{{use function '__builtin_fabsl' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabsl" + (void)__builtin_fabsl(x); + + (void)__builtin_cabsf(x); + // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of floating point type}} + // expected-note@-2 {{use function '__builtin_fabsl' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsl" + (void)__builtin_cabs(x); + // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of floating point type}} + // expected-note@-2 {{use function '__builtin_fabsl' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabsl" + (void)__builtin_cabsl(x); + // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of floating point type}} + // expected-note@-2 {{use function '__builtin_fabsl' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsl" +} + +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_complex_double(_Complex 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 'cabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabs" + (void)labs(x); + // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of complex type}} + // expected-note@-2 {{use function 'cabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabs" + (void)llabs(x); + // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of complex type}} + // expected-note@-2 {{use function 'cabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs" + + (void)fabsf(x); + // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of complex type}} + // expected-note@-2 {{use function 'cabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs" + (void)fabs(x); + // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of complex type}} + // expected-note@-2 {{use function 'cabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabs" + (void)fabsl(x); + // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of complex type}} + // expected-note@-2 {{use function 'cabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs" + + (void)cabsf(x); + // 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}} + // expected-note@-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@-1 {{using integer absolute value function '__builtin_abs' when argument is of complex type}} + // expected-note@-2 {{use function '__builtin_cabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_cabs" + (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_cabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabs" + (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_cabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs" + + (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_cabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs" + (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_cabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabs" + (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_cabs' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs" + + (void)__builtin_cabsf(x); + // 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}} + // expected-note@-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@-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_unsigned_int(unsigned int x) { + (void)abs(x); + // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' 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 int' 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 int' 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 int' 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 int' 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 int' 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 int' 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 int' 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 int' 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 int' 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 int' 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 int' 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 int' 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 int' 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 int' 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 int' 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 int' 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 int' 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_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}:"" +} + diff --git a/clang/test/SemaCXX/warn-absolute-value-header.cpp b/clang/test/SemaCXX/warn-absolute-value-header.cpp new file mode 100644 index 00000000000..01aaabcc002 --- /dev/null +++ b/clang/test/SemaCXX/warn-absolute-value-header.cpp @@ -0,0 +1,37 @@ +// 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); + +// Wrong signature +int fabsf(int); + +void test_int(int i, unsigned u, long long ll, float f, double d) { + (void)abs(i); + + // Remove abs call + (void)abs(u); + // expected-warning@-1{{taking the absolute value of unsigned type 'unsigned int' 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}:"" + + int llabs; + (void)llabs; + // Conflict in names, suggest qualified name + (void)abs(ll); + // 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}} + // expected-note@-3{{please include the header <stdlib.h> or explicitly provide a declaration for 'llabs'}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:12}:"::llabs" + + // Conflict in names, no notes + (void)abs(f); + // expected-warning@-1{{using integer absolute value function 'abs' when argument is of floating point type}} + + // Suggest header. + (void)abs(d); + // expected-warning@-1{{using integer absolute value function 'abs' when argument is of floating point type}} + // expected-note@-2{{use function 'fabs' instead}} + // expected-note@-3{{please include the header <math.h> or explicitly provide a declaration for 'fabs'}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:12}:"fabs" +} |

