<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Feb 25, 2014 at 5:17 PM, Richard Trieu <span dir="ltr"><<a href="mailto:rtrieu@google.com" target="_blank">rtrieu@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: rtrieu<br>
Date: Tue Feb 25 19:17:28 2014<br>
New Revision: 202211<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=202211&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=202211&view=rev</a><br>
Log:<br>
Add -Wabsolute-value, warnings about absolute value functions.<br>
<br>
The warnings fall into three groups.<br>
1) Using an absolute value function of the wrong type, for instance, using the<br>
int absolute value function when the argument is a floating point type.<br>
2) Using the improper sized absolute value function, for instance, using abs<br>
when the argument is a long long.  llabs should be used instead.<br>
<br>
>From these two cases, an implicit conversion will occur which may cause<br>
unexpected behavior.  Where possible, suggest the proper absolute value<br>
function to use, and which header to include if the function is not available.<br>
<br>
3) Taking the absolute value of an unsigned value.  In addition to this warning,<br>
suggest to remove the function call.  This usually indicates a logic error<br>
since the programmer assumed negative values would have been possible.<br>
<br>
Added:<br>
    cfe/trunk/test/Sema/warn-absolute-value-header.c<br>
    cfe/trunk/test/Sema/warn-absolute-value.c<br>
    cfe/trunk/test/SemaCXX/warn-absolute-value-header.cpp<br>
Modified:<br>
    cfe/trunk/include/clang/Basic/DiagnosticGroups.td<br>
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
    cfe/trunk/include/clang/Sema/Sema.h<br>
    cfe/trunk/lib/Sema/SemaChecking.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=202211&r1=202210&r2=202211&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=202211&r1=202210&r2=202211&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Feb 25 19:17:28 2014<br>
@@ -18,6 +18,7 @@ def Implicit : DiagGroup<"implicit", [<br>
<br>
 // Empty DiagGroups are recognized by clang but ignored.<br>
 def : DiagGroup<"abi">;<br>
+def AbsoluteValue : DiagGroup<"absolute-value">;<br>
 def : DiagGroup<"address">;<br>
 def AddressOfTemporary : DiagGroup<"address-of-temporary">;<br>
 def : DiagGroup<"aggregate-return">;<br>
<br>
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=202211&r1=202210&r2=202211&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=202211&r1=202210&r2=202211&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Feb 25 19:17:28 2014<br>
@@ -30,6 +30,21 @@ def warn_duplicate_enum_values : Warning<br>
   "been assigned">, InGroup<DiagGroup<"duplicate-enum">>, DefaultIgnore;<br>
 def note_duplicate_element : Note<"element %0 also has value %1">;<br>
<br>
+// Absolute value functions<br>
+def warn_unsigned_abs : Warning<<br>
+  "taking the absolute value of unsigned type %0 has no effect">,<br>
+  InGroup<AbsoluteValue>;<br>
+def note_remove_abs : Note<<br>
+  "remove the call to %0 since unsigned values cannot be negative">;<br>
+def warn_abs_too_small : Warning<<br>
+  "absolute value function %0 given an argument of type %1 but has parameter "<br>
+  "of type %2 which may cause truncation of value">, InGroup<AbsoluteValue>;<br>
+def warn_wrong_absolute_value_type : Warning<<br>
+  "using %select{integer|floating point|complex}1 absolute value function %0 "<br>
+  "when argument is of %select{integer|floating point|complex}2 type">,<br>
+  InGroup<AbsoluteValue>;<br>
+def note_replace_abs_function : Note<"use function '%0' instead">;<br>
+<br>
 def warn_infinite_recursive_function : Warning<<br>
   "all paths through this function will call itself">,<br>
   InGroup<InfiniteRecursion>, DefaultIgnore;<br>
<br>
Modified: cfe/trunk/include/clang/Sema/Sema.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=202211&r1=202210&r2=202211&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=202211&r1=202210&r2=202211&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/Sema/Sema.h (original)<br>
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Feb 25 19:17:28 2014<br>
@@ -7941,6 +7941,10 @@ private:<br>
                             SourceLocation Loc, SourceRange range,<br>
                             llvm::SmallBitVector &CheckedVarArgs);<br>
<br>
+  void CheckAbsoluteValueFunction(const CallExpr *Call,<br>
+                                  const FunctionDecl *FDecl,<br>
+                                  IdentifierInfo *FnInfo);<br>
+<br>
   void CheckMemaccessArguments(const CallExpr *Call,<br>
                                unsigned BId,<br>
                                IdentifierInfo *FnName);<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=202211&r1=202210&r2=202211&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=202211&r1=202210&r2=202211&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Feb 25 19:17:28 2014<br>
@@ -851,6 +851,8 @@ bool Sema::CheckFunctionCall(FunctionDec<br>
   if (!FnInfo)<br>
     return false;<br>
<br>
+  CheckAbsoluteValueFunction(TheCall, FDecl, FnInfo);<br>
+<br>
   unsigned CMId = FDecl->getMemoryFunctionKind();<br>
   if (CMId == 0)<br>
     return false;<br>
@@ -3582,6 +3584,328 @@ void Sema::CheckFormatString(const Strin<br>
   } // TODO: handle other formats<br>
 }<br>
<br>
+//===--- CHECK: Warn on use of wrong absolute value function. -------------===//<br>
+<br>
+// Returns the related absolute value function that is larger, of 0 if one<br>
+// does not exist.<br>
+static unsigned getLargerAbsoluteValueFunction(unsigned AbsFunction) {<br>
+  switch (AbsFunction) {<br>
+  default:<br>
+    return 0;<br>
+<br>
+  case Builtin::BI__builtin_abs:<br>
+    return Builtin::BI__builtin_labs;<br>
+  case Builtin::BI__builtin_labs:<br>
+    return Builtin::BI__builtin_llabs;<br>
+  case Builtin::BI__builtin_llabs:<br>
+    return 0;<br>
+<br>
+  case Builtin::BI__builtin_fabsf:<br>
+    return Builtin::BI__builtin_fabs;<br>
+  case Builtin::BI__builtin_fabs:<br>
+    return Builtin::BI__builtin_fabsl;<br>
+  case Builtin::BI__builtin_fabsl:<br>
+    return 0;<br>
+<br>
+  case Builtin::BI__builtin_cabsf:<br>
+    return Builtin::BI__builtin_cabs;<br>
+  case Builtin::BI__builtin_cabs:<br>
+    return Builtin::BI__builtin_cabsl;<br>
+  case Builtin::BI__builtin_cabsl:<br>
+    return 0;<br>
+<br>
+  case Builtin::BIabs:<br>
+    return Builtin::BIlabs;<br>
+  case Builtin::BIlabs:<br>
+    return Builtin::BIllabs;<br>
+  case Builtin::BIllabs:<br>
+    return 0;<br>
+<br>
+  case Builtin::BIfabsf:<br>
+    return Builtin::BIfabs;<br>
+  case Builtin::BIfabs:<br>
+    return Builtin::BIfabsl;<br>
+  case Builtin::BIfabsl:<br>
+    return 0;<br>
+<br>
+  case Builtin::BIcabsf:<br>
+   return Builtin::BIcabs;<br>
+  case Builtin::BIcabs:<br>
+    return Builtin::BIcabsl;<br>
+  case Builtin::BIcabsl:<br>
+    return 0;<br>
+  }<br>
+}<br>
+<br>
+// Returns the argument type of the absolute value function.<br>
+static QualType getAbsoluteValueArgumentType(ASTContext &Context,<br>
+                                             unsigned AbsType) {<br>
+  if (AbsType == 0)<br>
+    return QualType();<br>
+<br>
+  ASTContext::GetBuiltinTypeError Error = ASTContext::GE_None;<br>
+  QualType BuiltinType = Context.GetBuiltinType(AbsType, Error);<br>
+  if (Error != ASTContext::GE_None)<br>
+    return QualType();<br>
+<br>
+  const FunctionProtoType *FT = BuiltinType->getAs<FunctionProtoType>();<br>
+  if (!FT)<br>
+    return QualType();<br>
+<br>
+  if (FT->getNumParams() != 1)<br>
+    return QualType();<br>
+<br>
+  return FT->getParamType(0);<br>
+}<br>
+<br>
+// Returns the best absolute value function, or zero, based on type and<br>
+// current absolute value function.<br>
+static unsigned getBestAbsFunction(ASTContext &Context, QualType ArgType,<br>
+                                   unsigned AbsFunctionKind) {<br>
+  unsigned BestKind = 0;<br>
+  uint64_t ArgSize = Context.getTypeSize(ArgType);<br>
+  for (unsigned Kind = AbsFunctionKind; Kind != 0;<br>
+       Kind = getLargerAbsoluteValueFunction(Kind)) {<br>
+    QualType ParamType = getAbsoluteValueArgumentType(Context, Kind);<br>
+    if (Context.getTypeSize(ParamType) >= ArgSize) {<br>
+      if (BestKind == 0)<br>
+        BestKind = Kind;<br>
+      else if (Context.hasSameType(ParamType, ArgType)) {<br>
+        BestKind = Kind;<br>
+        break;<br>
+      }<br>
+    }<br>
+  }<br>
+  return BestKind;<br>
+}<br>
+<br>
+enum AbsoluteValueKind {<br>
+  AVK_Integer,<br>
+  AVK_Floating,<br>
+  AVK_Complex<br>
+};<br>
+<br>
+static AbsoluteValueKind getAbsoluteValueKind(QualType T) {<br>
+  if (T->isIntegralOrEnumerationType())<br>
+    return AVK_Integer;<br>
+  if (T->isRealFloatingType())<br>
+    return AVK_Floating;<br>
+  if (T->isAnyComplexType())<br>
+    return AVK_Complex;<br>
+<br>
+  llvm_unreachable("Type not integer, floating, or complex");<br>
+}<br>
+<br>
+// Changes the absolute value function to a different type.  Preserves whether<br>
+// the function is a builtin.<br>
+static unsigned changeAbsFunction(unsigned AbsKind,<br>
+                                  AbsoluteValueKind ValueKind) {<br>
+  switch (ValueKind) {<br>
+  case AVK_Integer:<br>
+    switch (AbsKind) {<br>
+    default:<br>
+      return 0;<br>
+    case Builtin::BI__builtin_fabsf:<br>
+    case Builtin::BI__builtin_fabs:<br>
+    case Builtin::BI__builtin_fabsl:<br>
+    case Builtin::BI__builtin_cabsf:<br>
+    case Builtin::BI__builtin_cabs:<br>
+    case Builtin::BI__builtin_cabsl:<br>
+      return Builtin::BI__builtin_abs;<br>
+    case Builtin::BIfabsf:<br>
+    case Builtin::BIfabs:<br>
+    case Builtin::BIfabsl:<br>
+    case Builtin::BIcabsf:<br>
+    case Builtin::BIcabs:<br>
+    case Builtin::BIcabsl:<br>
+      return Builtin::BIabs;<br>
+    }<br>
+  case AVK_Floating:<br>
+    switch (AbsKind) {<br>
+    default:<br>
+      return 0;<br>
+    case Builtin::BI__builtin_abs:<br>
+    case Builtin::BI__builtin_labs:<br>
+    case Builtin::BI__builtin_llabs:<br>
+    case Builtin::BI__builtin_cabsf:<br>
+    case Builtin::BI__builtin_cabs:<br>
+    case Builtin::BI__builtin_cabsl:<br>
+      return Builtin::BI__builtin_fabsf;<br>
+    case Builtin::BIabs:<br>
+    case Builtin::BIlabs:<br>
+    case Builtin::BIllabs:<br>
+    case Builtin::BIcabsf:<br>
+    case Builtin::BIcabs:<br>
+    case Builtin::BIcabsl:<br>
+      return Builtin::BIfabsf;<br>
+    }<br>
+  case AVK_Complex:<br>
+    switch (AbsKind) {<br>
+    default:<br>
+      return 0;<br>
+    case Builtin::BI__builtin_abs:<br>
+    case Builtin::BI__builtin_labs:<br>
+    case Builtin::BI__builtin_llabs:<br>
+    case Builtin::BI__builtin_fabsf:<br>
+    case Builtin::BI__builtin_fabs:<br>
+    case Builtin::BI__builtin_fabsl:<br>
+      return Builtin::BI__builtin_cabsf;<br>
+    case Builtin::BIabs:<br>
+    case Builtin::BIlabs:<br>
+    case Builtin::BIllabs:<br>
+    case Builtin::BIfabsf:<br>
+    case Builtin::BIfabs:<br>
+    case Builtin::BIfabsl:<br>
+      return Builtin::BIcabsf;<br>
+    }<br>
+  }<br>
+  llvm_unreachable("Unable to convert function");<br>
+}<br>
+<br>
+unsigned getAbsoluteValueFunctionKind(const FunctionDecl *FDecl) {<br>
+  const IdentifierInfo *FnInfo = FDecl->getIdentifier();<br>
+  if (!FnInfo)<br>
+    return 0;<br>
+<br>
+  switch (FDecl->getBuiltinID()) {<br>
+  default:<br>
+    return 0;<br>
+  case Builtin::BI__builtin_abs:<br>
+  case Builtin::BI__builtin_fabs:<br>
+  case Builtin::BI__builtin_fabsf:<br>
+  case Builtin::BI__builtin_fabsl:<br>
+  case Builtin::BI__builtin_labs:<br>
+  case Builtin::BI__builtin_llabs:<br>
+  case Builtin::BI__builtin_cabs:<br>
+  case Builtin::BI__builtin_cabsf:<br>
+  case Builtin::BI__builtin_cabsl:<br>
+  case Builtin::BIabs:<br>
+  case Builtin::BIlabs:<br>
+  case Builtin::BIllabs:<br>
+  case Builtin::BIfabs:<br>
+  case Builtin::BIfabsf:<br>
+  case Builtin::BIfabsl:<br>
+  case Builtin::BIcabs:<br>
+  case Builtin::BIcabsf:<br>
+  case Builtin::BIcabsl:<br>
+    return FDecl->getBuiltinID();<br>
+  }<br>
+  llvm_unreachable("Unknown Builtin type");<br>
+}<br>
+<br>
+// If the replacement is valid, emit a note with replacement function.<br>
+// Additionally, suggest including the proper header if not already included.<br>
+static void emitReplacement(Sema &S, SourceLocation Loc, SourceRange Range,<br>
+                            unsigned AbsKind) {<br>
+  std::string AbsName = S.Context.BuiltinInfo.GetName(AbsKind);<br>
+<br>
+  // Look up absolute value function in TU scope.<br>
+  DeclarationName DN(&S.Context.Idents.get(AbsName));<br>
+  LookupResult R(S, DN, Loc, Sema::LookupAnyName);<br></blockquote><div><br></div><div>This caused PR19015. I think you're just missing an 'R.suppressDiagnostics();' call here.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

+  S.LookupName(R, S.TUScope);<br>
+<br>
+  // Skip notes if multiple results found in lookup.<br>
+  if (!R.empty() && !R.isSingleResult())<br>
+    return;<br>
+<br>
+  FunctionDecl *FD = 0;<br>
+  bool FoundFunction = R.isSingleResult();<br>
+  // When one result is found, see if it is the correct function.<br>
+  if (R.isSingleResult()) {<br>
+    FD = dyn_cast<FunctionDecl>(R.getFoundDecl());<br>
+    if (!FD || FD->getBuiltinID() != AbsKind)<br>
+      return;<br>
+  }<br>
+<br>
+  // Look for local name conflict, prepend "::" as necessary.<br>
+  R.clear();<br>
+  S.LookupName(R, S.getCurScope());<br>
+<br>
+  if (!FoundFunction) {<br>
+    if (!R.empty()) {<br>
+      AbsName = "::" + AbsName;<br>
+    }<br>
+  } else { // FoundFunction<br>
+    if (R.isSingleResult()) {<br>
+      if (R.getFoundDecl() != FD) {<br>
+        AbsName = "::" + AbsName;<br>
+      }<br>
+    } else if (!R.empty()) {<br>
+      AbsName = "::" + AbsName;<br>
+    }<br>
+  }<br>
+<br>
+  S.Diag(Loc, diag::note_replace_abs_function)<br>
+      << AbsName << FixItHint::CreateReplacement(Range, AbsName);<br>
+<br>
+  if (!FoundFunction) {<br>
+    S.Diag(Loc, diag::note_please_include_header)<br>
+        << S.Context.BuiltinInfo.getHeaderName(AbsKind)<br>
+        << S.Context.BuiltinInfo.GetName(AbsKind);<br>
+  }<br>
+}<br>
+<br>
+// Warn when using the wrong abs() function.<br>
+void Sema::CheckAbsoluteValueFunction(const CallExpr *Call,<br>
+                                      const FunctionDecl *FDecl,<br>
+                                      IdentifierInfo *FnInfo) {<br>
+  if (Call->getNumArgs() != 1)<br>
+    return;<br>
+<br>
+  unsigned AbsKind = getAbsoluteValueFunctionKind(FDecl);<br>
+  if (AbsKind == 0)<br>
+    return;<br>
+<br>
+  QualType ArgType = Call->getArg(0)->IgnoreParenImpCasts()->getType();<br>
+  QualType ParamType = Call->getArg(0)->getType();<br>
+<br>
+  // Unsigned types can not be negative.  Suggest to drop the absolute value<br>
+  // function.<br>
+  if (ArgType->isUnsignedIntegerType()) {<br>
+    Diag(Call->getExprLoc(), diag::warn_unsigned_abs) << ArgType << ParamType;<br>
+    Diag(Call->getExprLoc(), diag::note_remove_abs)<br>
+        << FDecl<br>
+        << FixItHint::CreateRemoval(Call->getCallee()->getSourceRange());<br>
+    return;<br>
+  }<br>
+<br>
+  AbsoluteValueKind ArgValueKind = getAbsoluteValueKind(ArgType);<br>
+  AbsoluteValueKind ParamValueKind = getAbsoluteValueKind(ParamType);<br>
+<br>
+  // The argument and parameter are the same kind.  Check if they are the right<br>
+  // size.<br>
+  if (ArgValueKind == ParamValueKind) {<br>
+    if (Context.getTypeSize(ArgType) <= Context.getTypeSize(ParamType))<br>
+      return;<br>
+<br>
+    unsigned NewAbsKind = getBestAbsFunction(Context, ArgType, AbsKind);<br>
+    Diag(Call->getExprLoc(), diag::warn_abs_too_small)<br>
+        << FDecl << ArgType << ParamType;<br>
+<br>
+    if (NewAbsKind == 0)<br>
+      return;<br>
+<br>
+    emitReplacement(*this, Call->getExprLoc(),<br>
+                    Call->getCallee()->getSourceRange(), NewAbsKind);<br>
+    return;<br>
+  }<br>
+<br>
+  // ArgValueKind != ParamValueKind<br>
+  // The wrong type of absolute value function was used.  Attempt to find the<br>
+  // proper one.<br>
+  unsigned NewAbsKind = changeAbsFunction(AbsKind, ArgValueKind);<br>
+  NewAbsKind = getBestAbsFunction(Context, ArgType, NewAbsKind);<br>
+  if (NewAbsKind == 0)<br>
+    return;<br>
+<br>
+  Diag(Call->getExprLoc(), diag::warn_wrong_absolute_value_type)<br>
+      << FDecl << ParamValueKind << ArgValueKind;<br>
+<br>
+  emitReplacement(*this, Call->getExprLoc(),<br>
+                  Call->getCallee()->getSourceRange(), NewAbsKind);<br>
+  return;<br>
+}<br>
+<br>
 //===--- CHECK: Standard memory functions ---------------------------------===//<br>
<br>
 /// \brief Takes the expression passed to the size_t parameter of functions<br>
@@ -7518,3 +7842,4 @@ void Sema::CheckArgumentWithTypeTag(cons<br>
         << ArgumentExpr->getSourceRange()<br>
         << TypeTagExpr->getSourceRange();<br>
 }<br>
+<br>
<br>
Added: cfe/trunk/test/Sema/warn-absolute-value-header.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-absolute-value-header.c?rev=202211&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-absolute-value-header.c?rev=202211&view=auto</a><br>

==============================================================================<br>
--- cfe/trunk/test/Sema/warn-absolute-value-header.c (added)<br>
+++ cfe/trunk/test/Sema/warn-absolute-value-header.c Tue Feb 25 19:17:28 2014<br>
@@ -0,0 +1,36 @@<br>
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify %s -Wabsolute-value<br>
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only %s -Wabsolute-value -fdiagnostics-parseable-fixits 2>&1 | FileCheck %s<br>
+<br>
+int abs(int);<br>
+<br>
+// Wrong signature<br>
+int fabsf(int);<br>
+// expected-warning@-1{{incompatible redeclaration of library function 'fabsf'}}<br>
+// expected-note@-2{{'fabsf' is a builtin with type 'float (float)'}}<br>
+<br>
+void test_int(int i, unsigned u, long long ll, float f, double d) {<br>
+  (void)abs(i);<br>
+<br>
+  // Remove abs call<br>
+  (void)abs(u);<br>
+  // expected-warning@-1{{taking the absolute value of unsigned type 'unsigned int' has no effect}}<br>
+  // expected-note@-2{{remove the call to 'abs' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:""<br>
+<br>
+  int llabs;<br>
+  (void)llabs;<br>
+  // Conflict in names, no notes<br>
+  (void)abs(ll);<br>
+  // 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}}<br>
+<br>
+  // Conflict in names, no notes<br>
+  (void)abs(f);<br>
+  // expected-warning@-1{{using integer absolute value function 'abs' when argument is of floating point type}}<br>
+<br>
+  // Suggest header.<br>
+  (void)abs(d);<br>
+  // expected-warning@-1{{using integer absolute value function 'abs' when argument is of floating point type}}<br>
+  // expected-note@-2{{use function 'fabs' instead}}<br>
+  // expected-note@-3{{please include the header <math.h> or explicitly provide a declaration for 'fabs'}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:12}:"fabs"<br>
+}<br>
<br>
Added: cfe/trunk/test/Sema/warn-absolute-value.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-absolute-value.c?rev=202211&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-absolute-value.c?rev=202211&view=auto</a><br>

==============================================================================<br>
--- cfe/trunk/test/Sema/warn-absolute-value.c (added)<br>
+++ cfe/trunk/test/Sema/warn-absolute-value.c Tue Feb 25 19:17:28 2014<br>
@@ -0,0 +1,782 @@<br>
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify %s -Wabsolute-value<br>
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only %s -Wabsolute-value -fdiagnostics-parseable-fixits 2>&1 | FileCheck %s<br>
+<br>
+int abs(int);<br>
+long int labs(long int);<br>
+long long int llabs(long long int);<br>
+<br>
+float fabsf(float);<br>
+double fabs(double);<br>
+long double fabsl(long double);<br>
+<br>
+float cabsf(float _Complex);<br>
+double cabs(double _Complex);<br>
+long double cabsl(long double _Complex);<br>
+<br>
+void test_int(int x) {<br>
+  (void)abs(x);<br>
+  (void)labs(x);<br>
+  (void)llabs(x);<br>
+<br>
+  (void)fabsf(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function 'abs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"abs"<br>
+  (void)fabs(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function 'abs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"abs"<br>
+  (void)fabsl(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function 'abs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"abs"<br>
+<br>
+  (void)cabsf(x);<br>
+  // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function 'abs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"abs"<br>
+  (void)cabs(x);<br>
+  // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function 'abs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"abs"<br>
+  (void)cabsl(x);<br>
+  // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function 'abs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"abs"<br>
+<br>
+  (void)__builtin_abs(x);<br>
+  (void)__builtin_labs(x);<br>
+  (void)__builtin_llabs(x);<br>
+<br>
+  (void)__builtin_fabsf(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function '__builtin_abs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_abs"<br>
+  (void)__builtin_fabs(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function '__builtin_abs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_abs"<br>
+  (void)__builtin_fabsl(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function '__builtin_abs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_abs"<br>
+<br>
+  (void)__builtin_cabsf(x);<br>
+  // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function '__builtin_abs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_abs"<br>
+  (void)__builtin_cabs(x);<br>
+  // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function '__builtin_abs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_abs"<br>
+  (void)__builtin_cabsl(x);<br>
+  // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function '__builtin_abs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_abs"<br>
+}<br>
+<br>
+void test_long(long x) {<br>
+  (void)abs(x);  // no warning - int and long are same length for this target<br>
+  (void)labs(x);<br>
+  (void)llabs(x);<br>
+<br>
+  (void)fabsf(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function 'labs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs"<br>
+  (void)fabs(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function 'labs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"labs"<br>
+  (void)fabsl(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function 'labs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs"<br>
+<br>
+  (void)cabsf(x);<br>
+  // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function 'labs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs"<br>
+  (void)cabs(x);<br>
+  // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function 'labs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"labs"<br>
+  (void)cabsl(x);<br>
+  // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function 'labs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs"<br>
+<br>
+  (void)__builtin_abs(x);  // no warning - int and long are same length for<br>
+                           // this target<br>
+  (void)__builtin_labs(x);<br>
+  (void)__builtin_llabs(x);<br>
+<br>
+  (void)__builtin_fabsf(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function '__builtin_labs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs"<br>
+  (void)__builtin_fabs(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function '__builtin_labs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_labs"<br>
+  (void)__builtin_fabsl(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function '__builtin_labs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs"<br>
+<br>
+  (void)__builtin_cabsf(x);<br>
+  // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function '__builtin_labs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs"<br>
+  (void)__builtin_cabs(x);<br>
+  // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function '__builtin_labs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_labs"<br>
+  (void)__builtin_cabsl(x);<br>
+  // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function '__builtin_labs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs"<br>
+}<br>
+<br>
+void test_long_long(long long x) {<br>
+  (void)abs(x);<br>
+  // 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}}<br>
+  // expected-note@-2{{use function 'llabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"llabs"<br>
+  (void)labs(x);<br>
+  // 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}}<br>
+  // expected-note@-2{{use function 'llabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"llabs"<br>
+  (void)llabs(x);<br>
+<br>
+  (void)fabsf(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function 'llabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs"<br>
+  (void)fabs(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function 'llabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"llabs"<br>
+  (void)fabsl(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function 'llabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs"<br>
+<br>
+  (void)cabsf(x);<br>
+  // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function 'llabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs"<br>
+  (void)cabs(x);<br>
+  // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function 'llabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"llabs"<br>
+  (void)cabsl(x);<br>
+  // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function 'llabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs"<br>
+<br>
+  (void)__builtin_abs(x);<br>
+  // 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}}<br>
+  // expected-note@-2{{use function '__builtin_llabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_llabs"<br>
+  (void)__builtin_labs(x);<br>
+  // 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}}<br>
+  // expected-note@-2{{use function '__builtin_llabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_llabs"<br>
+  (void)__builtin_llabs(x);<br>
+<br>
+  (void)__builtin_fabsf(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function '__builtin_llabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs"<br>
+  (void)__builtin_fabs(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function '__builtin_llabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_llabs"<br>
+  (void)__builtin_fabsl(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function '__builtin_llabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs"<br>
+<br>
+  (void)__builtin_cabsf(x);<br>
+  // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function '__builtin_llabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs"<br>
+  (void)__builtin_cabs(x);<br>
+  // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function '__builtin_llabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_llabs"<br>
+  (void)__builtin_cabsl(x);<br>
+  // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}}<br>
+  // expected-note@-2 {{use function '__builtin_llabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs"<br>
+}<br>
+<br>
+void test_float(float x) {<br>
+  (void)abs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function 'fabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"fabsf"<br>
+  (void)labs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function 'fabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabsf"<br>
+  (void)llabs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function 'fabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsf"<br>
+<br>
+  (void)fabsf(x);<br>
+  (void)fabs(x);<br>
+  (void)fabsl(x);<br>
+<br>
+  (void)cabsf(x);<br>
+  // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function 'fabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsf"<br>
+  (void)cabs(x);<br>
+  // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function 'fabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabsf"<br>
+  (void)cabsl(x);<br>
+  // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function 'fabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsf"<br>
+<br>
+  (void)__builtin_abs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function '__builtin_fabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_fabsf"<br>
+  (void)__builtin_labs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function '__builtin_fabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabsf"<br>
+  (void)__builtin_llabs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function '__builtin_fabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsf"<br>
+<br>
+  (void)__builtin_fabsf(x);<br>
+  (void)__builtin_fabs(x);<br>
+  (void)__builtin_fabsl(x);<br>
+<br>
+  (void)__builtin_cabsf(x);<br>
+  // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function '__builtin_fabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsf"<br>
+  (void)__builtin_cabs(x);<br>
+  // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function '__builtin_fabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabsf"<br>
+  (void)__builtin_cabsl(x);<br>
+  // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function '__builtin_fabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsf"<br>
+}<br>
+<br>
+void test_double(double x) {<br>
+  (void)abs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function 'fabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"fabs"<br>
+  (void)labs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function 'fabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabs"<br>
+  (void)llabs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function 'fabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabs"<br>
+<br>
+  (void)fabsf(x);<br>
+  // 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}}<br>
+  // expected-note@-2{{use function 'fabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabs"<br>
+  (void)fabs(x);<br>
+  (void)fabsl(x);<br>
+<br>
+  (void)cabsf(x);<br>
+  // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function 'fabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabs"<br>
+  (void)cabs(x);<br>
+  // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function 'fabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabs"<br>
+  (void)cabsl(x);<br>
+  // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function 'fabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabs"<br>
+<br>
+  (void)__builtin_abs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function '__builtin_fabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_fabs"<br>
+  (void)__builtin_labs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function '__builtin_fabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabs"<br>
+  (void)__builtin_llabs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function '__builtin_fabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabs"<br>
+<br>
+  (void)__builtin_fabsf(x);<br>
+  // 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}}<br>
+  // expected-note@-2{{use function '__builtin_fabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabs"<br>
+  (void)__builtin_fabs(x);<br>
+  (void)__builtin_fabsl(x);<br>
+<br>
+  (void)__builtin_cabsf(x);<br>
+  // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function '__builtin_fabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabs"<br>
+  (void)__builtin_cabs(x);<br>
+  // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function '__builtin_fabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabs"<br>
+  (void)__builtin_cabsl(x);<br>
+  // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function '__builtin_fabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabs"<br>
+}<br>
+<br>
+void test_long_double(long double x) {<br>
+  (void)abs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function 'fabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"fabsl"<br>
+  (void)labs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function 'fabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabsl"<br>
+  (void)llabs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function 'fabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsl"<br>
+<br>
+  (void)fabsf(x);<br>
+  // 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}}<br>
+  // expected-note@-2{{use function 'fabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsl"<br>
+  (void)fabs(x);<br>
+  // 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}}<br>
+  // expected-note@-2{{use function 'fabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabsl"<br>
+  (void)fabsl(x);<br>
+<br>
+  (void)cabsf(x);<br>
+  // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function 'fabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsl"<br>
+  (void)cabs(x);<br>
+  // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function 'fabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabsl"<br>
+  (void)cabsl(x);<br>
+  // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function 'fabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsl"<br>
+<br>
+  (void)__builtin_abs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function '__builtin_fabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_fabsl"<br>
+  (void)__builtin_labs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function '__builtin_fabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabsl"<br>
+  (void)__builtin_llabs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function '__builtin_fabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsl"<br>
+<br>
+  (void)__builtin_fabsf(x);<br>
+  // 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}}<br>
+  // expected-note@-2{{use function '__builtin_fabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsl"<br>
+  (void)__builtin_fabs(x);<br>
+  // 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}}<br>
+  // expected-note@-2{{use function '__builtin_fabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabsl"<br>
+  (void)__builtin_fabsl(x);<br>
+<br>
+  (void)__builtin_cabsf(x);<br>
+  // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function '__builtin_fabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsl"<br>
+  (void)__builtin_cabs(x);<br>
+  // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function '__builtin_fabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabsl"<br>
+  (void)__builtin_cabsl(x);<br>
+  // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of floating point type}}<br>
+  // expected-note@-2 {{use function '__builtin_fabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsl"<br>
+}<br>
+<br>
+void test_complex_float(_Complex float x) {<br>
+  (void)abs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function 'cabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabsf"<br>
+  (void)labs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function 'cabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsf"<br>
+  (void)llabs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function 'cabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf"<br>
+<br>
+  (void)fabsf(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function 'cabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf"<br>
+  (void)fabs(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function 'cabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsf"<br>
+  (void)fabsl(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function 'cabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf"<br>
+<br>
+  (void)cabsf(x);<br>
+  (void)cabs(x);<br>
+  (void)cabsl(x);<br>
+<br>
+  (void)__builtin_abs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function '__builtin_cabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_cabsf"<br>
+  (void)__builtin_labs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function '__builtin_cabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsf"<br>
+  (void)__builtin_llabs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function '__builtin_cabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf"<br>
+<br>
+  (void)__builtin_fabsf(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function '__builtin_cabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf"<br>
+  (void)__builtin_fabs(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function '__builtin_cabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsf"<br>
+  (void)__builtin_fabsl(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function '__builtin_cabsf' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf"<br>
+<br>
+  (void)__builtin_cabsf(x);<br>
+  (void)__builtin_cabs(x);<br>
+  (void)__builtin_cabsl(x);<br>
+}<br>
+<br>
+void test_complex_double(_Complex double x) {<br>
+  (void)abs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function 'cabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabs"<br>
+  (void)labs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function 'cabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabs"<br>
+  (void)llabs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function 'cabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs"<br>
+<br>
+  (void)fabsf(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function 'cabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs"<br>
+  (void)fabs(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function 'cabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabs"<br>
+  (void)fabsl(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function 'cabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs"<br>
+<br>
+  (void)cabsf(x);<br>
+  // 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}}<br>
+  // expected-note@-2 {{use function 'cabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs"<br>
+  (void)cabs(x);<br>
+  (void)cabsl(x);<br>
+<br>
+  (void)__builtin_abs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function '__builtin_cabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_cabs"<br>
+  (void)__builtin_labs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function '__builtin_cabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabs"<br>
+  (void)__builtin_llabs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function '__builtin_cabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs"<br>
+<br>
+  (void)__builtin_fabsf(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function '__builtin_cabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs"<br>
+  (void)__builtin_fabs(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function '__builtin_cabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabs"<br>
+  (void)__builtin_fabsl(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function '__builtin_cabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs"<br>
+<br>
+  (void)__builtin_cabsf(x);<br>
+  // 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}}<br>

+  // expected-note@-2 {{use function '__builtin_cabs' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs"<br>
+  (void)__builtin_cabs(x);<br>
+  (void)__builtin_cabsl(x);<br>
+}<br>
+<br>
+void test_complex_long_double(_Complex long double x) {<br>
+  (void)abs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function 'cabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabsl"<br>
+  (void)labs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function 'cabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl"<br>
+  (void)llabs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function 'cabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"<br>
+<br>
+  (void)fabsf(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function 'cabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"<br>
+  (void)fabs(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function 'cabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl"<br>
+  (void)fabsl(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function 'cabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"<br>
+<br>
+  (void)cabsf(x);<br>
+  // 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}}<br>
+  // expected-note@-2 {{use function 'cabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"<br>
+  (void)cabs(x);<br>
+  // 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}}<br>
+  // expected-note@-2 {{use function 'cabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl"<br>
+  (void)cabsl(x);<br>
+<br>
+  (void)__builtin_abs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function '__builtin_cabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_cabsl"<br>
+  (void)__builtin_labs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function '__builtin_cabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl"<br>
+  (void)__builtin_llabs(x);<br>
+  // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function '__builtin_cabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl"<br>
+<br>
+  (void)__builtin_fabsf(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function '__builtin_cabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl"<br>
+  (void)__builtin_fabs(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function '__builtin_cabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl"<br>
+  (void)__builtin_fabsl(x);<br>
+  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of complex type}}<br>
+  // expected-note@-2 {{use function '__builtin_cabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl"<br>
+<br>
+  (void)__builtin_cabsf(x);<br>
+  // 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}}<br>

+  // expected-note@-2 {{use function '__builtin_cabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl"<br>
+  (void)__builtin_cabs(x);<br>
+  // 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}}<br>

+  // expected-note@-2 {{use function '__builtin_cabsl' instead}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl"<br>
+  (void)__builtin_cabsl(x);<br>
+}<br>
+<br>
+void test_unsigned_int(unsigned int x) {<br>
+  (void)abs(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}<br>
+  // expected-note@-2 {{remove the call to 'abs' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:""<br>
+  (void)labs(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}<br>
+  // expected-note@-2 {{remove the call to 'labs' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""<br>
+  (void)llabs(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}<br>
+  // expected-note@-2 {{remove the call to 'llabs' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""<br>
+<br>
+  (void)fabsf(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}<br>
+  // expected-note@-2 {{remove the call to 'fabsf' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""<br>
+  (void)fabs(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}<br>
+  // expected-note@-2 {{remove the call to 'fabs' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""<br>
+  (void)fabsl(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}<br>
+  // expected-note@-2 {{remove the call to 'fabsl' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""<br>
+<br>
+  (void)cabsf(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}<br>
+  // expected-note@-2 {{remove the call to 'cabsf' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""<br>
+  (void)cabs(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}<br>
+  // expected-note@-2 {{remove the call to 'cabs' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""<br>
+  (void)cabsl(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}<br>
+  // expected-note@-2 {{remove the call to 'cabsl' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""<br>
+<br>
+  (void)__builtin_abs(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}<br>
+  // expected-note@-2 {{remove the call to '__builtin_abs' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:""<br>
+  (void)__builtin_labs(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}<br>
+  // expected-note@-2 {{remove the call to '__builtin_labs' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""<br>
+  (void)__builtin_llabs(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}<br>
+  // expected-note@-2 {{remove the call to '__builtin_llabs' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""<br>
+<br>
+  (void)__builtin_fabsf(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}<br>
+  // expected-note@-2 {{remove the call to '__builtin_fabsf' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""<br>
+  (void)__builtin_fabs(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}<br>
+  // expected-note@-2 {{remove the call to '__builtin_fabs' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""<br>
+  (void)__builtin_fabsl(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}<br>
+  // expected-note@-2 {{remove the call to '__builtin_fabsl' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""<br>
+<br>
+  (void)__builtin_cabsf(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}<br>
+  // expected-note@-2 {{remove the call to '__builtin_cabsf' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""<br>
+  (void)__builtin_cabs(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}<br>
+  // expected-note@-2 {{remove the call to '__builtin_cabs' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""<br>
+  (void)__builtin_cabsl(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}<br>
+  // expected-note@-2 {{remove the call to '__builtin_cabsl' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""<br>
+}<br>
+<br>
+void test_unsigned_long(unsigned long x) {<br>
+  (void)abs(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}<br>
+  // expected-note@-2 {{remove the call to 'abs' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:""<br>
+  (void)labs(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}<br>
+  // expected-note@-2 {{remove the call to 'labs' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""<br>
+  (void)llabs(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}<br>
+  // expected-note@-2 {{remove the call to 'llabs' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""<br>
+<br>
+  (void)fabsf(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}<br>
+  // expected-note@-2 {{remove the call to 'fabsf' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""<br>
+  (void)fabs(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}<br>
+  // expected-note@-2 {{remove the call to 'fabs' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""<br>
+  (void)fabsl(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}<br>
+  // expected-note@-2 {{remove the call to 'fabsl' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""<br>
+<br>
+  (void)cabsf(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}<br>
+  // expected-note@-2 {{remove the call to 'cabsf' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""<br>
+  (void)cabs(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}<br>
+  // expected-note@-2 {{remove the call to 'cabs' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""<br>
+  (void)cabsl(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}<br>
+  // expected-note@-2 {{remove the call to 'cabsl' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""<br>
+<br>
+  (void)__builtin_abs(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}<br>
+  // expected-note@-2 {{remove the call to '__builtin_abs' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:""<br>
+  (void)__builtin_labs(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}<br>
+  // expected-note@-2 {{remove the call to '__builtin_labs' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""<br>
+  (void)__builtin_llabs(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}<br>
+  // expected-note@-2 {{remove the call to '__builtin_llabs' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""<br>
+<br>
+  (void)__builtin_fabsf(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}<br>
+  // expected-note@-2 {{remove the call to '__builtin_fabsf' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""<br>
+  (void)__builtin_fabs(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}<br>
+  // expected-note@-2 {{remove the call to '__builtin_fabs' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""<br>
+  (void)__builtin_fabsl(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}<br>
+  // expected-note@-2 {{remove the call to '__builtin_fabsl' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""<br>
+<br>
+  (void)__builtin_cabsf(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}<br>
+  // expected-note@-2 {{remove the call to '__builtin_cabsf' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""<br>
+  (void)__builtin_cabs(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}<br>
+  // expected-note@-2 {{remove the call to '__builtin_cabs' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""<br>
+  (void)__builtin_cabsl(x);<br>
+  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}<br>
+  // expected-note@-2 {{remove the call to '__builtin_cabsl' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""<br>
+}<br>
+<br>
<br>
Added: cfe/trunk/test/SemaCXX/warn-absolute-value-header.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-absolute-value-header.cpp?rev=202211&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-absolute-value-header.cpp?rev=202211&view=auto</a><br>

==============================================================================<br>
--- cfe/trunk/test/SemaCXX/warn-absolute-value-header.cpp (added)<br>
+++ cfe/trunk/test/SemaCXX/warn-absolute-value-header.cpp Tue Feb 25 19:17:28 2014<br>
@@ -0,0 +1,37 @@<br>
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify %s -Wabsolute-value<br>
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only %s -Wabsolute-value -fdiagnostics-parseable-fixits 2>&1 | FileCheck %s<br>
+<br>
+extern "C" int abs(int);<br>
+<br>
+// Wrong signature<br>
+int fabsf(int);<br>
+<br>
+void test_int(int i, unsigned u, long long ll, float f, double d) {<br>
+  (void)abs(i);<br>
+<br>
+  // Remove abs call<br>
+  (void)abs(u);<br>
+  // expected-warning@-1{{taking the absolute value of unsigned type 'unsigned int' has no effect}}<br>
+  // expected-note@-2{{remove the call to 'abs' since unsigned values cannot be negative}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:""<br>
+<br>
+  int llabs;<br>
+  (void)llabs;<br>
+  // Conflict in names, suggest qualified name<br>
+  (void)abs(ll);<br>
+  // 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}}<br>
+  // expected-note@-2{{use function '::llabs' instead}}<br>
+  // expected-note@-3{{please include the header <stdlib.h> or explicitly provide a declaration for 'llabs'}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:12}:"::llabs"<br>
+<br>
+  // Conflict in names, no notes<br>
+  (void)abs(f);<br>
+  // expected-warning@-1{{using integer absolute value function 'abs' when argument is of floating point type}}<br>
+<br>
+  // Suggest header.<br>
+  (void)abs(d);<br>
+  // expected-warning@-1{{using integer absolute value function 'abs' when argument is of floating point type}}<br>
+  // expected-note@-2{{use function 'fabs' instead}}<br>
+  // expected-note@-3{{please include the header <math.h> or explicitly provide a declaration for 'fabs'}}<br>
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:12}:"fabs"<br>
+}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>