[go: nahoru, domu]

disable clang integer overflow warnings for safe_numerics unittests

Some of these tests intentionally cause overflow, and it seems that clang
ToT is now able to recognise and warn about this.  Let's disable these
warnings as we do for MSVC.

Bug: 826656

Change-Id: I7a455e4d5b901c2638154da9d8d7ef99531286b0
Reviewed-on: https://chromium-review.googlesource.com/984876
Commit-Queue: Mostyn Bramley-Moore <mostynb@vewd.com>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546598}
diff --git a/base/safe_numerics_unittest.cc b/base/safe_numerics_unittest.cc
index dac79b4..44675cf 100644
--- a/base/safe_numerics_unittest.cc
+++ b/base/safe_numerics_unittest.cc
@@ -18,6 +18,13 @@
 #pragma warning(disable : 4293)  // Invalid shift.
 #endif
 
+// This may not need to come before the base/numerics headers, but let's keep
+// it close to the MSVC equivalent.
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Winteger-overflow"
+#endif
+
 #include "base/logging.h"
 #include "base/numerics/safe_conversions.h"
 #include "base/numerics/safe_math.h"
@@ -1625,5 +1632,9 @@
   }
 }
 
+#if defined(__clang__)
+#pragma clang diagnostic pop  // -Winteger-overflow
+#endif
+
 }  // namespace internal
 }  // namespace base