[PATCH] D65859: [LLVM][Alignment] Fix MSVC warning

Guillaume Chatelet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 7 04:42:50 PDT 2019


gchatelet created this revision.
gchatelet added a reviewer: RKSimon.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65859

Files:
  llvm/unittests/Support/AlignmentTest.cpp


Index: llvm/unittests/Support/AlignmentTest.cpp
===================================================================
--- llvm/unittests/Support/AlignmentTest.cpp
+++ llvm/unittests/Support/AlignmentTest.cpp
@@ -247,9 +247,19 @@
 TEST(AlignmentDeathTest, Division) {
   EXPECT_DEATH(Align(1) / 2, "Can't halve byte alignment");
   EXPECT_DEATH(MaybeAlign(1) / 2, "Can't halve byte alignment");
+  EXPECT_DEATH(Align(8) / 3, "Divisor must be positive and a power of 2");
+}
 
+TEST(AlignmentDeathTest, DivisionbyZero) {
+#ifdef _MSC_VER
+// Disable warnings about potential divide by 0.
+#pragma warning(push)
+#pragma warning(disable : 4723)
+#endif
   EXPECT_DEATH(Align(8) / 0, "Divisor must be positive and a power of 2");
-  EXPECT_DEATH(Align(8) / 3, "Divisor must be positive and a power of 2");
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
 }
 
 TEST(AlignmentDeathTest, InvalidCTors) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65859.213850.patch
Type: text/x-patch
Size: 894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190807/46bd751e/attachment.bin>


More information about the llvm-commits mailing list