]> granicus.if.org Git - clang/commitdiff
Suppress diagnostics during name lookup for absolute value type.
authorRichard Trieu <rtrieu@google.com>
Thu, 6 Mar 2014 02:25:04 +0000 (02:25 +0000)
committerRichard Trieu <rtrieu@google.com>
Thu, 6 Mar 2014 02:25:04 +0000 (02:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203061 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaChecking.cpp
test/SemaCXX/warn-absolute-value2.cpp [new file with mode: 0644]

index 7bf1071d6717f6a9fcbdf706229ad0e48ad9daa4..dd7cb5855f235309f061307318782583ba59a61f 100644 (file)
@@ -3817,6 +3817,7 @@ static void emitReplacement(Sema &S, SourceLocation Loc, SourceRange Range,
   // Look up absolute value function in TU scope.
   DeclarationName DN(&S.Context.Idents.get(AbsName));
   LookupResult R(S, DN, Loc, Sema::LookupAnyName);
+  R.suppressDiagnostics();
   S.LookupName(R, S.TUScope);
 
   // Skip notes if multiple results found in lookup.
diff --git a/test/SemaCXX/warn-absolute-value2.cpp b/test/SemaCXX/warn-absolute-value2.cpp
new file mode 100644 (file)
index 0000000..2affcb1
--- /dev/null
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify %s -Wabsolute-value
+
+extern "C" {
+int abs(int);
+long labs(long);
+}
+
+using ::labs;
+
+long test(long x) {
+  return ::abs(x);
+  // expected-warning@-1{{using integer absolute value function 'abs' when argument is of floating point type}}
+}