[libcxx-commits] [PATCH] D117422: [libcxx][test] compiler options are non-portable

Casey Carter via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jan 16 01:55:03 PST 2022


CaseyCarter created this revision.
CaseyCarter added a reviewer: libc++.
CaseyCarter added a project: libc++.
CaseyCarter requested review of this revision.
Herald added 1 blocking reviewer(s): libc++.

... it's easier to suppress warnings internally, where we can detect the compiler.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117422

Files:
  libcxx/test/std/library/description/conventions/expos.only.func/synth_three_way.pass.cpp
  libcxx/test/std/ranges/range.factories/range.iota.view/ctor.value.bound.pass.cpp
  libcxx/test/std/ranges/range.factories/range.iota.view/end.pass.cpp
  libcxx/test/std/ranges/range.factories/range.iota.view/iterator/star.pass.cpp
  libcxx/test/std/utilities/tuple/tuple.tuple/tuple.rel/three_way.pass.cpp


Index: libcxx/test/std/utilities/tuple/tuple.tuple/tuple.rel/three_way.pass.cpp
===================================================================
--- libcxx/test/std/utilities/tuple/tuple.tuple/tuple.rel/three_way.pass.cpp
+++ libcxx/test/std/utilities/tuple/tuple.tuple/tuple.rel/three_way.pass.cpp
@@ -15,7 +15,12 @@
 //   operator<=>(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17, libcpp-no-concepts
-// ADDITIONAL_COMPILE_FLAGS: -Wno-sign-compare
+
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic ignored "-Wsign-compare"
+#elif defined(_MSC_VER)
+#pragma warning(disable: 4242 4244) // Various truncation warnings
+#endif
 
 #include <cassert>
 #include <compare>
Index: libcxx/test/std/ranges/range.factories/range.iota.view/iterator/star.pass.cpp
===================================================================
--- libcxx/test/std/ranges/range.factories/range.iota.view/iterator/star.pass.cpp
+++ libcxx/test/std/ranges/range.factories/range.iota.view/iterator/star.pass.cpp
@@ -10,10 +10,14 @@
 // UNSUPPORTED: libcpp-no-concepts
 // UNSUPPORTED: libcpp-has-no-incomplete-ranges
 
-// ADDITIONAL_COMPILE_FLAGS: -Wno-sign-compare
-
 // constexpr W operator*() const noexcept(is_nothrow_copy_constructible_v<W>);
 
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic ignored "-Wsign-compare"
+#elif defined(_MSC_VER)
+#pragma warning(disable: 4018) // various "signed/unsigned mismatch"
+#endif
+
 #include <ranges>
 #include <cassert>
 
Index: libcxx/test/std/ranges/range.factories/range.iota.view/end.pass.cpp
===================================================================
--- libcxx/test/std/ranges/range.factories/range.iota.view/end.pass.cpp
+++ libcxx/test/std/ranges/range.factories/range.iota.view/end.pass.cpp
@@ -10,7 +10,11 @@
 // UNSUPPORTED: libcpp-no-concepts
 // UNSUPPORTED: libcpp-has-no-incomplete-ranges
 
-// ADDITIONAL_COMPILE_FLAGS: -Wno-sign-compare
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic ignored "-Wsign-compare"
+#elif defined(_MSC_VER)
+#pragma warning(disable: 4018 4389) // various "signed/unsigned mismatch"
+#endif
 
 // constexpr auto end() const;
 // constexpr iterator end() const requires same_as<W, Bound>;
Index: libcxx/test/std/ranges/range.factories/range.iota.view/ctor.value.bound.pass.cpp
===================================================================
--- libcxx/test/std/ranges/range.factories/range.iota.view/ctor.value.bound.pass.cpp
+++ libcxx/test/std/ranges/range.factories/range.iota.view/ctor.value.bound.pass.cpp
@@ -10,7 +10,11 @@
 // UNSUPPORTED: libcpp-no-concepts
 // UNSUPPORTED: libcpp-has-no-incomplete-ranges
 
-// ADDITIONAL_COMPILE_FLAGS: -Wno-sign-compare
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic ignored "-Wsign-compare"
+#elif defined(_MSC_VER)
+#pragma warning(disable: 4018 4389) // various "signed/unsigned mismatch"
+#endif
 
 // constexpr iota_view(type_identity_t<W> value, type_identity_t<Bound> bound);
 
@@ -57,4 +61,3 @@
 
   return 0;
 }
-
Index: libcxx/test/std/library/description/conventions/expos.only.func/synth_three_way.pass.cpp
===================================================================
--- libcxx/test/std/library/description/conventions/expos.only.func/synth_three_way.pass.cpp
+++ libcxx/test/std/library/description/conventions/expos.only.func/synth_three_way.pass.cpp
@@ -7,11 +7,16 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17, libcpp-no-concepts
-// ADDITIONAL_COMPILE_FLAGS: -Wno-sign-compare
 
 // constexpr auto synth-three-way = ...;
 //   via std::tuple<T>(t) <=> std::tuple<U>(u), which exposes its behavior most directly
 
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic ignored "-Wsign-compare"
+#elif defined(_MSC_VER)
+#pragma warning(disable: 4242 4244) // Various truncation warnings
+#endif
+
 #include <cassert>
 #include <compare>
 #include <limits>  // quiet_NaN


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117422.400357.patch
Type: text/x-patch
Size: 4058 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220116/91c49a53/attachment.bin>


More information about the libcxx-commits mailing list