[libc++][test] Use TEST_MEOW_DIAGNOSTIC_IGNORED instead of ADDITIONAL_COMPILE_FLAGS#75133
[libc++][test] Use TEST_MEOW_DIAGNOSTIC_IGNORED instead of ADDITIONAL_COMPILE_FLAGS#75133StephanTLavavej wants to merge 6 commits intollvm:mainfrom
TEST_MEOW_DIAGNOSTIC_IGNORED instead of ADDITIONAL_COMPILE_FLAGS#75133Conversation
…rnings. * Don't use libc++-internal macros, which msvc_stdlib_force_include.h had to simulate. * Suppress the warnings in the entire test (as it was already doing for `TEST_COMPILER_GCC`), no need to push/pop. * The libc++-internal macro was ignoring the coarse-grained "-Wdeprecated" (plus "-Wdeprecated-declarations" which is irrelevant here, and omitted from msvc_stdlib_force_include.h's simulation). Instead, we can ignore the fine-grained "-Wdeprecated-volatile" for Clang and "-Wvolatile" for GCC. (Interestingly, they both understand "-Wdeprecated", but "-Wdeprecated-volatile" and "-Wvolatile" are mutually unintelligible, at least as of Clang 17.0.1 and GCC 13.2.) * Add a comment for what MSVC warning C5215 is. * We don't need to ignore MSVC warning C4996 about `result_of` being deprecated; we've already defined the finer-grained `_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS`.
….cpp to use someday.
|
@llvm/pr-subscribers-libcxx Author: Stephan T. Lavavej (StephanTLavavej) ChangesFound while running libc++'s tests with MSVC's STL. This is an alternative to my original PR #74974. @cpplearner suggested in #74974 (comment) that we should follow the precedent of using these macros: This PR does so throughout Additional notes:
Patch is 39.17 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/75133.diff 36 Files Affected:
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.replace/ranges.replace.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.replace/ranges.replace.pass.cpp
index ab2f705bafe9d0..31468cc4c13dff 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.replace/ranges.replace.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.replace/ranges.replace.pass.cpp
@@ -21,6 +21,11 @@
// constexpr borrowed_iterator_t<R>
// ranges::replace(R&& r, const T1& old_value, const T2& new_value, Proj proj = {});
+#include "test_macros.h"
+
+// MSVC warning C4244: 'argument': conversion from 'const _Ty2' to 'T', possible loss of data
+TEST_MSVC_DIAGNOSTIC_IGNORED(4244)
+
#include <algorithm>
#include <array>
#include <cassert>
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp
index e28cbe2a08de4a..1f9cb9b9cee5a7 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp
@@ -18,15 +18,21 @@
// constexpr bool // constexpr after c++17
// equal(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
+#include "test_macros.h"
+
// We test the cartesian product, so we sometimes compare differently signed types
-// ADDITIONAL_COMPILE_FLAGS: -Wno-sign-compare
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wsign-compare")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Wsign-compare")
+// MSVC warning C4242: 'argument': conversion from 'int' to 'const _Ty', possible loss of data
+// MSVC warning C4244: 'argument': conversion from 'wchar_t' to 'const _Ty', possible loss of data
+// MSVC warning C4389: '==': signed/unsigned mismatch
+TEST_MSVC_DIAGNOSTIC_IGNORED(4242 4244 4389)
#include <algorithm>
#include <cassert>
#include <functional>
#include "test_iterators.h"
-#include "test_macros.h"
#include "type_algorithms.h"
template <class UnderlyingType, class Iter1>
@@ -58,6 +64,10 @@ struct Test {
struct TestNarrowingEqualTo {
template <class UnderlyingType>
TEST_CONSTEXPR_CXX20 void operator()() {
+ TEST_DIAGNOSTIC_PUSH
+ // MSVC warning C4310: cast truncates constant value
+ TEST_MSVC_DIAGNOSTIC_IGNORED(4310)
+
UnderlyingType a[] = {
UnderlyingType(0x1000),
UnderlyingType(0x1001),
@@ -71,6 +81,8 @@ struct TestNarrowingEqualTo {
UnderlyingType(0x1603),
UnderlyingType(0x1604)};
+ TEST_DIAGNOSTIC_POP
+
assert(std::equal(a, a + 5, b, std::equal_to<char>()));
#if TEST_STD_VER >= 14
assert(std::equal(a, a + 5, b, b + 5, std::equal_to<char>()));
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.find/find.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.find/find.pass.cpp
index b55a852c10cafa..be65683c373699 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.find/find.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.find/find.pass.cpp
@@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// ADDITIONAL_COMPILE_FLAGS: -Wno-sign-compare
-
// <algorithm>
// template<InputIterator Iter, class T>
@@ -15,12 +13,18 @@
// constexpr Iter // constexpr after C++17
// find(Iter first, Iter last, const T& value);
+#include "test_macros.h"
+
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wsign-compare")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Wsign-compare")
+// MSVC warning C4389: '==': signed/unsigned mismatch
+TEST_MSVC_DIAGNOSTIC_IGNORED(4389)
+
#include <algorithm>
#include <cassert>
#include <vector>
#include <type_traits>
-#include "test_macros.h"
#include "test_iterators.h"
#include "type_algorithms.h"
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.find/ranges.find.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.find/ranges.find.pass.cpp
index 22f938f73ae078..994fb3daf6b980 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.find/ranges.find.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.find/ranges.find.pass.cpp
@@ -10,8 +10,6 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17
-// ADDITIONAL_COMPILE_FLAGS: -Wno-sign-compare
-
// template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity>
// requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
// constexpr I ranges::find(I first, S last, const T& value, Proj proj = {});
@@ -20,6 +18,14 @@
// constexpr borrowed_iterator_t<R>
// ranges::find(R&& r, const T& value, Proj proj = {});
+#include "test_macros.h"
+
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wsign-compare")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Wsign-compare")
+// MSVC warning C4242: 'argument': conversion from 'const _Ty' to 'ElementT', possible loss of data
+// MSVC warning C4244: 'argument': conversion from 'const _Ty' to 'ElementT', possible loss of data
+TEST_MSVC_DIAGNOSTIC_IGNORED(4242 4244)
+
#include <algorithm>
#include <array>
#include <cassert>
diff --git a/libcxx/test/std/atomics/atomics.types.generic/general.compile.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/general.compile.pass.cpp
index 9f2a28256184ce..fead6e2e5f6c2c 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/general.compile.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/general.compile.pass.cpp
@@ -74,9 +74,15 @@ void test() {
TEST_IGNORE_NODISCARD a.is_lock_free();
+ TEST_DIAGNOSTIC_PUSH
+ // MSVC warning C4197: 'volatile std::atomic<operator_hijacker>': top-level volatile in cast is ignored
+ TEST_MSVC_DIAGNOSTIC_IGNORED(4197)
+
TEST_IGNORE_NODISCARD T();
TEST_IGNORE_NODISCARD T(v);
+ TEST_DIAGNOSTIC_POP
+
TEST_IGNORE_NODISCARD a.load();
TEST_IGNORE_NODISCARD static_cast<typename T::value_type>(a);
a.store(v);
diff --git a/libcxx/test/std/atomics/atomics.types.generic/pointer.compile.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/pointer.compile.pass.cpp
index 9049beaa9c7897..961aed3b4fb1a9 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/pointer.compile.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/pointer.compile.pass.cpp
@@ -98,8 +98,16 @@ void test() {
a.store(v);
a = v;
+
+ TEST_DIAGNOSTIC_PUSH
+ // MSVC warning C4197: 'volatile std::atomic<operator_hijacker *>': top-level volatile in cast is ignored
+ TEST_MSVC_DIAGNOSTIC_IGNORED(4197)
+
TEST_IGNORE_NODISCARD T();
TEST_IGNORE_NODISCARD T(v);
+
+ TEST_DIAGNOSTIC_POP
+
TEST_IGNORE_NODISCARD a.load();
TEST_IGNORE_NODISCARD static_cast<typename T::value_type>(a);
TEST_IGNORE_NODISCARD* a;
diff --git a/libcxx/test/std/concepts/concepts.lang/concept.default.init/default_initializable.compile.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concept.default.init/default_initializable.compile.pass.cpp
index 4921a48bcccc17..152978166ccfcf 100644
--- a/libcxx/test/std/concepts/concepts.lang/concept.default.init/default_initializable.compile.pass.cpp
+++ b/libcxx/test/std/concepts/concepts.lang/concept.default.init/default_initializable.compile.pass.cpp
@@ -8,15 +8,18 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17
-// We voluntarily use std::default_initializable on types that have redundant
-// or ignored cv-qualifiers -- don't warn about it.
-// ADDITIONAL_COMPILE_FLAGS: -Wno-ignored-qualifiers
-
// template<class T>
// concept default_initializable = constructible_from<T> &&
// requires { T{}; } &&
// is-default-initializable<T>;
+#include "test_macros.h"
+
+// We voluntarily use std::default_initializable on types that have redundant
+// or ignored cv-qualifiers -- don't warn about it.
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wignored-qualifiers")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Wignored-qualifiers")
+
#include <array>
#include <concepts>
#include <deque>
@@ -34,8 +37,6 @@
#include <unordered_set>
#include <vector>
-#include "test_macros.h"
-
struct Empty {};
struct CtorDefaulted {
diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_range.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_range.pass.cpp
index 1d7fe7193facf4..00be60d15d4528 100644
--- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_range.pass.cpp
+++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_range.pass.cpp
@@ -7,18 +7,21 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
-// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
-// ADDITIONAL_COMPILE_FLAGS: -Wno-missing-field-initializers
// <map>
// template<container-compatible-range<value_type> R>
// void insert_range(R&& rg); // C++23
+#include "test_macros.h"
+
+// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
+
#include <map>
#include "../../../insert_range_maps_sets.h"
-#include "test_macros.h"
int main(int, char**) {
// Note: we want to use a pair with non-const elements for input (an assignable type is a lot more convenient) but
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_range.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_range.pass.cpp
index c7c05a896bc9f9..4d289ffeefb4af 100644
--- a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_range.pass.cpp
+++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_range.pass.cpp
@@ -7,18 +7,21 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
-// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
-// ADDITIONAL_COMPILE_FLAGS: -Wno-missing-field-initializers
// <map>
// template<container-compatible-range<value_type> R>
// void insert_range(R&& rg); // C++23
+#include "test_macros.h"
+
+// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
+
#include <map>
#include "../../../insert_range_maps_sets.h"
-#include "test_macros.h"
int main(int, char**) {
// Note: we want to use a pair with non-const elements for input (an assignable type is a lot more convenient) but
@@ -38,4 +41,3 @@ int main(int, char**) {
return 0;
}
-
diff --git a/libcxx/test/std/containers/associative/multiset/insert_range.pass.cpp b/libcxx/test/std/containers/associative/multiset/insert_range.pass.cpp
index 9dd85eea47c290..fbe0097292ed9a 100644
--- a/libcxx/test/std/containers/associative/multiset/insert_range.pass.cpp
+++ b/libcxx/test/std/containers/associative/multiset/insert_range.pass.cpp
@@ -7,18 +7,21 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
-// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
-// ADDITIONAL_COMPILE_FLAGS: -Wno-missing-field-initializers
// <set>
// template<container-compatible-range<value_type> R>
// void insert_range(R&& rg); // C++23
+#include "test_macros.h"
+
+// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
+
#include <set>
#include "../../insert_range_maps_sets.h"
-#include "test_macros.h"
int main(int, char**) {
for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
diff --git a/libcxx/test/std/containers/associative/set/insert_range.pass.cpp b/libcxx/test/std/containers/associative/set/insert_range.pass.cpp
index 1956fc6bd7f3ea..bf51f5366af941 100644
--- a/libcxx/test/std/containers/associative/set/insert_range.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/insert_range.pass.cpp
@@ -7,18 +7,21 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
-// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
-// ADDITIONAL_COMPILE_FLAGS: -Wno-missing-field-initializers
// <set>
// template<container-compatible-range<value_type> R>
// void insert_range(R&& rg); // C++23
+#include "test_macros.h"
+
+// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
+
#include <set>
#include "../../insert_range_maps_sets.h"
-#include "test_macros.h"
int main(int, char**) {
for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
diff --git a/libcxx/test/std/containers/sequences/array/array.tuple/get.verify.cpp b/libcxx/test/std/containers/sequences/array/array.tuple/get.verify.cpp
index 9052b4359f6b0a..d96b23082ef4fb 100644
--- a/libcxx/test/std/containers/sequences/array/array.tuple/get.verify.cpp
+++ b/libcxx/test/std/containers/sequences/array/array.tuple/get.verify.cpp
@@ -10,8 +10,11 @@
// template <size_t I, class T, size_t N> T& get(array<T, N>& a);
+#include "test_macros.h"
+
// Prevent -Warray-bounds from issuing a diagnostic when testing with clang verify.
-// ADDITIONAL_COMPILE_FLAGS: -Wno-array-bounds
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Warray-bounds")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Warray-bounds")
#include <array>
#include <cassert>
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_range.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_range.pass.cpp
index 8b004336f68cde..a482a57168a4fd 100644
--- a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_range.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_range.pass.cpp
@@ -7,18 +7,21 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
-// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
-// ADDITIONAL_COMPILE_FLAGS: -Wno-missing-field-initializers
// <unordered_map>
// template<container-compatible-range<value_type> R>
// void insert_range(R&& rg); // C++23
+#include "test_macros.h"
+
+// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
+
#include <unordered_map>
#include "../../../insert_range_maps_sets.h"
-#include "test_macros.h"
int main(int, char**) {
// Note: we want to use a pair with non-const elements for input (an assignable type is a lot more convenient) but
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp
index fcde119f487030..8de0bb28e9b840 100644
--- a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp
@@ -7,18 +7,21 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
-// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
-// ADDITIONAL_COMPILE_FLAGS: -Wno-missing-field-initializers
// <unordered_map>
// template<container-compatible-range<value_type> R>
// void insert_range(R&& rg); // C++23
+#include "test_macros.h"
+
+// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
+
#include <unordered_map>
#include "../../../insert_range_maps_sets.h"
-#include "test_macros.h"
int main(int, char**) {
// Note: we want to use a pair with non-const elements for input (an assignable type is a lot more convenient) but
@@ -38,4 +41,3 @@ int main(int, char**) {
return 0;
}
-
diff --git a/libcxx/test/std/containers/unord/unord.multiset/insert_range.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/insert_range.pass.cpp
index 73ac4cf071e1bb..5444eeaad57319 100644
--- a/libcxx/test/std/containers/unord/unord.multiset/insert_range.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.multiset/insert_range.pass.cpp
@@ -7,18 +7,21 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
-// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
-// ADDITIONAL_COMPILE_FLAGS: -Wno-missing-field-initializers
// <set>
// template<container-compatible-range<value_type> R>
// void insert_range(R&& rg); // C++23
+#include "test_macros.h"
+
+// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
+
#include <unordered_set>
#include "../../insert_range_maps_sets.h"
-#include "test_macros.h"
int main(int, char**) {
for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
@@ -34,4 +37,3 @@ int main(int, char**) {
return 0;
}
-
diff --git a/libcxx/test/std/containers/unord/unord.set/insert_range.pass.cpp b/libcxx/test/std/containers/unord/unord.set/insert_range.pass.cpp
index c6306a28b7adb5..c8c7be2d69073e 100644
--- a/libcxx/test/std/containers/unord/unord.set/insert_range.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.set/insert_range.pass.cpp
@@ -7,18 +7,21 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
-// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
-// ADDITIONAL_COMPILE_FLAGS: -Wno-missing-field-initializers
// <set>
// template<container-compatible-range<value_type> R>
// void insert_range(R&& rg); // C++23
+#include "test_macros.h"
+
+// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
+
#include <unordered_set>
#include "../../insert_range_maps_sets.h"
-#include "test_macros.h"
int main(int, char**) {
for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
diff --git a/libcxx/test/std/containers/views/mdspan/layout_stride/deduction.pass.cpp b/libcxx/test/std/containers/views/mdspan/layout_stride/deduction.pass.cpp
index 0e0a079b598bc0..a7a6cf693bb69d 100644
--- a/libcxx/test/std/containers/views/mdspan/layout_stride/deduction.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/layout_stride/deduction.pass.cpp
@@ -6,17 +6,19 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
-// ADDITIONAL_COMPILE_FLAGS: -Wno-ctad-maybe-unsupported
// <mdspan>
+#include "test_macros.h"
+
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wctad-maybe-unsupported")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Wctad-maybe-unsupported")
+
#include <mdspan>
#include <type_traits>
#include <concepts>
#include <cassert>
-#include "test_macros.h"
-
// mdspan
// layout_stride::mapping does not h...
[truncated]
|
|
philnik777
left a comment
There was a problem hiding this comment.
I'm not a huge fan of this approach. It results in this weird dance of first including test_macros.h, then disabling some warnings and after that include other headers. To be clear, I think it's a good idea to use them in places where we only want to disable warnings for a few lines. That's what they were intended for. But I don't think it's a good idea if we want to disable a warning for the whole file.
|
I'll prepare another PR to go back to the original approach, keeping the uncontroversial improvements of this approach. |
Found while running libc++'s tests with MSVC's STL.
This is an alternative to my original PR #74974. @cpplearner suggested in #74974 (comment) that we should follow the precedent of using these macros:
llvm-project/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.rel/three_way.pass.cpp
Lines 19 to 23 in 59f3661
This PR does so throughout
libcxx/test/std, converting existing Clang/GCC warning suppressions, and adding MSVC warning suppressions. (As usual, I'm not tooled up to work onlibcxx/test/libcxx, so a followup PR should change that subdirectory if desired.)Additional notes:
#include "test_macros.h"to the top of the test, then ignore diagnostics. However, in a few cases, the MSVC warnings are very specific and I can locally suppress them with push/ignore/pop.test_macros.h, I'm addingTEST_MEOW_DIAGNOSTIC_ERRORforlibcxx/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cppto use someday. (Note thatdiagnostic erroris intentional;diagnostic warningmeans "treat as a warning even under-Werror" as GCC documents and Clang follows.)advance.pass.cpp.libcxx/test/std/utilities/variant/variant.variant/implicit_ctad.pass.cpp.libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cppsuppresses "deprecated volatile" warnings.msvc_stdlib_force_include.hhad to simulate.TEST_COMPILER_GCC), no need to push/pop.-Wdeprecated(plus-Wdeprecated-declarationswhich is irrelevant here, and omitted frommsvc_stdlib_force_include.h's simulation). Instead, we can ignore the fine-grained-Wdeprecated-volatilefor Clang and-Wvolatilefor GCC. (Interestingly, they both understand-Wdeprecated, but-Wdeprecated-volatileand-Wvolatileare mutually unintelligible, at least as of Clang 17.0.1 and GCC 13.2.)result_ofbeing deprecated; we've already defined the finer-grained_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS.libcxx/test/std/utilities/meta/meta.unary/dependent_return_type.compile.pass.cppwas specifying// ADDITIONAL_COMPILE_FLAGS: -Wno-deprecated-volatile. I'm splitting that intoTEST_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-volatile")andTEST_GCC_DIAGNOSTIC_IGNORED("-Wvolatile"). I'm not sure why GCC wasn't complaining earlier.features.pydefines_isClangand_isGCC.ADDITIONAL_COMPILE_FLAGSto work with MSVC #74974 even though the other changes have been dropped.