[libcxx-commits] [libcxx] [libc++][test] Use `TEST_MEOW_DIAGNOSTIC_IGNORED` instead of `ADDITIONAL_COMPILE_FLAGS` (PR #75133)
Stephan T. Lavavej via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Dec 11 19:47:15 PST 2023
https://github.com/StephanTLavavej updated https://github.com/llvm/llvm-project/pull/75133
>From 41af43a57d1e07f457ec9a330c4fd64f98b9c650 Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Mon, 11 Dec 2023 14:53:21 -0800
Subject: [PATCH 1/6] Cleanup (NFC): Refactor how `features.py` defines
`_isClang` and `_isGCC`.
---
libcxx/utils/libcxx/test/features.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index 5e854917e6ef45..2a5d7c09026360 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -13,9 +13,11 @@
import subprocess
import sys
-_isClang = lambda cfg: "__clang__" in compilerMacros(cfg) and "__apple_build_version__" not in compilerMacros(cfg)
+_isAnyClang = lambda cfg: "__clang__" in compilerMacros(cfg)
_isAppleClang = lambda cfg: "__apple_build_version__" in compilerMacros(cfg)
-_isGCC = lambda cfg: "__GNUC__" in compilerMacros(cfg) and "__clang__" not in compilerMacros(cfg)
+_isAnyGCC = lambda cfg: "__GNUC__" in compilerMacros(cfg)
+_isClang = lambda cfg: _isAnyClang(cfg) and not _isAppleClang(cfg)
+_isGCC = lambda cfg: _isAnyGCC(cfg) and not _isAnyClang(cfg)
_isMSVC = lambda cfg: "_MSC_VER" in compilerMacros(cfg)
_msvcVersion = lambda cfg: (int(compilerMacros(cfg)["_MSC_VER"]) // 100, int(compilerMacros(cfg)["_MSC_VER"]) % 100)
>From 6a8bbd76174fd6dd07a12e8ed69a01ad96f2dea8 Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Mon, 11 Dec 2023 15:47:27 -0800
Subject: [PATCH 2/6] Overhaul how result_of11.pass.cpp suppresses "deprecated
volatile" warnings.
* 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`.
---
.../meta.trans/meta.trans.other/result_of11.pass.cpp | 12 ++++--------
libcxx/test/support/msvc_stdlib_force_include.h | 10 ----------
2 files changed, 4 insertions(+), 18 deletions(-)
diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp
index c1100916d90a9c..a4e41abc0660ff 100644
--- a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp
+++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp
@@ -23,9 +23,10 @@
// Ignore warnings about volatile in parameters being deprecated.
// We know it is, but we still have to test it.
-#if defined(TEST_COMPILER_GCC)
-# pragma GCC diagnostic ignored "-Wvolatile"
-#endif
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-volatile")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Wvolatile")
+// MSVC warning C5215: a function parameter with a volatile qualified type is deprecated in C++20
+TEST_MSVC_DIAGNOSTIC_IGNORED(5215)
struct wat
{
@@ -65,9 +66,6 @@ void test_result_of_imp()
#endif
}
-// Do not warn on deprecated uses of 'volatile' below.
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
-
int main(int, char**)
{
{
@@ -184,5 +182,3 @@ int main(int, char**)
return 0;
}
-
-_LIBCPP_SUPPRESS_DEPRECATED_POP
diff --git a/libcxx/test/support/msvc_stdlib_force_include.h b/libcxx/test/support/msvc_stdlib_force_include.h
index 5742bbf4f55726..c027dc5c851e56 100644
--- a/libcxx/test/support/msvc_stdlib_force_include.h
+++ b/libcxx/test/support/msvc_stdlib_force_include.h
@@ -104,14 +104,4 @@ const AssertionDialogAvoider assertion_dialog_avoider{};
#define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
-#ifdef __clang__
-# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
- _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated\"")
-# define _LIBCPP_SUPPRESS_DEPRECATED_POP _Pragma("GCC diagnostic pop")
-#else // ^^^ clang / MSVC vvv
-# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
- __pragma(warning(push)) __pragma(warning(disable : 4996)) __pragma(warning(disable : 5215))
-# define _LIBCPP_SUPPRESS_DEPRECATED_POP __pragma(warning(pop))
-#endif // __clang__
-
#endif // SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_H
>From 7554db9fd1d48d0f36eb4422f93e80686367514b Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Mon, 11 Dec 2023 17:27:39 -0800
Subject: [PATCH 3/6] Add `TEST_MEOW_DIAGNOSTIC_ERROR` for
iterator.operations/advance.pass.cpp to use someday.
---
.../iterator.operations/advance.pass.cpp | 12 ++++++------
libcxx/test/support/test_macros.h | 8 ++++++++
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/libcxx/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp b/libcxx/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp
index 8cf86407d7ad14..390fbcf9c279dd 100644
--- a/libcxx/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp
+++ b/libcxx/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp
@@ -19,22 +19,22 @@
// template <RandomAccessIterator Iter, class Distance>
// constexpr void advance(Iter& i, Distance n);
+#include "test_macros.h"
// TODO: test_iterators.h includes <ranges>, and <ranges> includes <chrono> and <atomic>.
-// Lots of implementation headers under <__chrono/> and <atomic> has signed to unsigned conversion,
-// which will trigger the -Wsign-conversion warning.
-// Once those headers are fixed, enable the -Wsign-conversion for this test by removing
-// <TODO:Remove brackets> below
+// Lots of implementation headers under <__chrono/> and <atomic> have signed to unsigned
+// conversions, which will trigger the -Wsign-conversion warning.
+// Once those headers are fixed, uncomment the following lines:
// Make sure we catch forced conversions to the difference_type if they happen.
-// ADDITIONAL_COMPILE_FLAGS<TODO:Remove brackets>: -Wsign-conversion
+// TEST_CLANG_DIAGNOSTIC_ERROR("-Wsign-conversion")
+// TEST_GCC_DIAGNOSTIC_ERROR("-Wsign-conversion")
#include <iterator>
#include <cassert>
#include <cstddef>
#include <type_traits>
-#include "test_macros.h"
#include "test_iterators.h"
template <class Distance, class It>
diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h
index ea289f0432e686..0997db82d28b6c 100644
--- a/libcxx/test/support/test_macros.h
+++ b/libcxx/test/support/test_macros.h
@@ -411,24 +411,32 @@ inline void DoNotOptimize(Tp const& value) {
# define TEST_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(TEST_STRINGIZE(clang diagnostic ignored str))
# define TEST_GCC_DIAGNOSTIC_IGNORED(str)
# define TEST_MSVC_DIAGNOSTIC_IGNORED(num)
+# define TEST_CLANG_DIAGNOSTIC_ERROR(str) _Pragma(TEST_STRINGIZE(clang diagnostic error str))
+# define TEST_GCC_DIAGNOSTIC_ERROR(str)
#elif defined(TEST_COMPILER_GCC)
# define TEST_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
# define TEST_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
# define TEST_CLANG_DIAGNOSTIC_IGNORED(str)
# define TEST_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(TEST_STRINGIZE(GCC diagnostic ignored str))
# define TEST_MSVC_DIAGNOSTIC_IGNORED(num)
+# define TEST_CLANG_DIAGNOSTIC_ERROR(str)
+# define TEST_GCC_DIAGNOSTIC_ERROR(str) _Pragma(TEST_STRINGIZE(GCC diagnostic error str))
#elif defined(TEST_COMPILER_MSVC)
# define TEST_DIAGNOSTIC_PUSH _Pragma("warning(push)")
# define TEST_DIAGNOSTIC_POP _Pragma("warning(pop)")
# define TEST_CLANG_DIAGNOSTIC_IGNORED(str)
# define TEST_GCC_DIAGNOSTIC_IGNORED(str)
# define TEST_MSVC_DIAGNOSTIC_IGNORED(num) _Pragma(TEST_STRINGIZE(warning(disable: num)))
+# define TEST_CLANG_DIAGNOSTIC_ERROR(str)
+# define TEST_GCC_DIAGNOSTIC_ERROR(str)
#else
# define TEST_DIAGNOSTIC_PUSH
# define TEST_DIAGNOSTIC_POP
# define TEST_CLANG_DIAGNOSTIC_IGNORED(str)
# define TEST_GCC_DIAGNOSTIC_IGNORED(str)
# define TEST_MSVC_DIAGNOSTIC_IGNORED(num)
+# define TEST_CLANG_DIAGNOSTIC_ERROR(str)
+# define TEST_GCC_DIAGNOSTIC_ERROR(str)
#endif
#if __has_cpp_attribute(msvc::no_unique_address)
>From d60112b16223638e6b5dc9ccba7dc6461e467436 Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Mon, 11 Dec 2023 17:14:11 -0800
Subject: [PATCH 4/6] Use `TEST_MEOW_DIAGNOSTIC_IGNORED` instead of
`ADDITIONAL_COMPILE_FLAGS`.
---
.../alg.replace/ranges.replace.pass.cpp | 5 +++++
.../alg.nonmodifying/alg.equal/equal.pass.cpp | 11 +++++++++--
.../alg.nonmodifying/alg.find/find.pass.cpp | 10 +++++++---
.../alg.nonmodifying/alg.find/ranges.find.pass.cpp | 10 ++++++++--
.../atomics.types.generic/general.compile.pass.cpp | 6 +++++-
.../atomics.types.generic/pointer.compile.pass.cpp | 6 +++++-
.../default_initializable.compile.pass.cpp | 13 +++++++------
.../map/map.modifiers/insert_range.pass.cpp | 9 ++++++---
.../multimap.modifiers/insert_range.pass.cpp | 10 ++++++----
.../associative/multiset/insert_range.pass.cpp | 9 ++++++---
.../associative/set/insert_range.pass.cpp | 9 ++++++---
.../sequences/array/array.tuple/get.verify.cpp | 5 ++++-
.../unord.map.modifiers/insert_range.pass.cpp | 9 ++++++---
.../unord.multimap.modifiers/insert_range.pass.cpp | 10 ++++++----
.../unord/unord.multiset/insert_range.pass.cpp | 10 ++++++----
.../unord/unord.set/insert_range.pass.cpp | 9 ++++++---
.../views/mdspan/layout_stride/deduction.pass.cpp | 8 +++++---
.../views/mdspan/mdspan/conversion.pass.cpp | 7 +++++--
.../depr/depr.c.headers/setjmp_h.compile.pass.cpp | 7 +++++--
.../deprecated.verify.cpp | 5 ++++-
.../ifstream.members/buffered_reads.pass.cpp | 7 ++++++-
.../ofstream.members/buffered_writes.pass.cpp | 7 ++++++-
.../support.runtime/csetjmp.pass.cpp | 5 +++++
.../range.lazy.split/constraints.compile.pass.cpp | 6 ++++++
.../range.utility/range.utility.conv/to.pass.cpp | 6 +++++-
.../string.cons/from_range_deduction.pass.cpp | 8 ++++++--
.../notify_all_at_thread_exit_lwg3343.pass.cpp | 6 +++++-
.../std/thread/thread.jthread/assign.move.pass.cpp | 7 +++++--
.../dependent_return_type.compile.pass.cpp | 9 ++++++---
.../unique.ptr.class/unique.ptr.asgn/move.pass.cpp | 10 ++++++----
.../variant/variant.variant/implicit_ctad.pass.cpp | 9 +++++----
31 files changed, 178 insertions(+), 70 deletions(-)
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..096bea7b74d242 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,22 @@
// 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 C4310: cast truncates constant value
+// MSVC warning C4389: '==': signed/unsigned mismatch
+TEST_MSVC_DIAGNOSTIC_IGNORED(4242 4244 4310 4389)
#include <algorithm>
#include <cassert>
#include <functional>
#include "test_iterators.h"
-#include "test_macros.h"
#include "type_algorithms.h"
template <class UnderlyingType, class Iter1>
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..f19d5de6ce3335 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
@@ -56,11 +56,15 @@
// void notify_all() noexcept;
// };
+#include "test_macros.h"
+
+// MSVC warning C4197: 'volatile std::atomic<operator_hijacker>': top-level volatile in cast is ignored
+TEST_MSVC_DIAGNOSTIC_IGNORED(4197)
+
#include <atomic>
#include <type_traits>
#include "operator_hijacker.h"
-#include "test_macros.h"
template <class T>
void test() {
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..26cfe1989f014e 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
@@ -78,11 +78,15 @@
// void notify_all() noexcept;
// };
+#include "test_macros.h"
+
+// MSVC warning C4197: 'volatile std::atomic<operator_hijacker *>': top-level volatile in cast is ignored
+TEST_MSVC_DIAGNOSTIC_IGNORED(4197)
+
#include <atomic>
#include <type_traits>
#include "operator_hijacker.h"
-#include "test_macros.h"
template <class T>
void test() {
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 have explicit deduction guides,
diff --git a/libcxx/test/std/containers/views/mdspan/mdspan/conversion.pass.cpp b/libcxx/test/std/containers/views/mdspan/mdspan/conversion.pass.cpp
index abb647e960c34e..6e463fd7337b4c 100644
--- a/libcxx/test/std/containers/views/mdspan/mdspan/conversion.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/mdspan/conversion.pass.cpp
@@ -35,13 +35,16 @@
// !is_convertible_v<const OtherLayoutPolicy::template mapping<OtherExtents>&, mapping_type>
// || !is_convertible_v<const OtherAccessor&, accessor_type>
+#include "test_macros.h"
+
+// MSVC warning C4244: 'initializing': conversion from '_Ty' to '_Ty', possible loss of data
+TEST_MSVC_DIAGNOSTIC_IGNORED(4244)
+
#include <mdspan>
#include <type_traits>
#include <concepts>
#include <cassert>
-#include "test_macros.h"
-
#include "../MinimalElementType.h"
#include "../CustomTestLayouts.h"
#include "CustomTestAccessors.h"
diff --git a/libcxx/test/std/depr/depr.c.headers/setjmp_h.compile.pass.cpp b/libcxx/test/std/depr/depr.c.headers/setjmp_h.compile.pass.cpp
index eaaeecbeb70ec8..3375d1327a111e 100644
--- a/libcxx/test/std/depr/depr.c.headers/setjmp_h.compile.pass.cpp
+++ b/libcxx/test/std/depr/depr.c.headers/setjmp_h.compile.pass.cpp
@@ -11,10 +11,13 @@
// Even though <setjmp.h> is not provided by libc++, we still test that
// using it with libc++ on the search path will work.
-#include <setjmp.h>
-
#include "test_macros.h"
+// MSVC warning C4611: interaction between '_setjmp' and C++ object destruction is non-portable
+TEST_MSVC_DIAGNOSTIC_IGNORED(4611)
+
+#include <setjmp.h>
+
jmp_buf jb;
ASSERT_SAME_TYPE(void, decltype(longjmp(jb, 0)));
diff --git a/libcxx/test/std/depr/depr.numeric.limits.has.denorm/deprecated.verify.cpp b/libcxx/test/std/depr/depr.numeric.limits.has.denorm/deprecated.verify.cpp
index 98d49de80a58cf..b9ad29f8ce56ec 100644
--- a/libcxx/test/std/depr/depr.numeric.limits.has.denorm/deprecated.verify.cpp
+++ b/libcxx/test/std/depr/depr.numeric.limits.has.denorm/deprecated.verify.cpp
@@ -8,7 +8,10 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
-// ADDITIONAL_COMPILE_FLAGS: -Wno-unused-value
+#include "test_macros.h"
+
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wunused-value")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Wunused-value")
#include <limits>
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.members/buffered_reads.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.members/buffered_reads.pass.cpp
index ecc11f4999ffa1..c57ab40d411a53 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.members/buffered_reads.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.members/buffered_reads.pass.cpp
@@ -29,6 +29,12 @@
// - Let the library manage a buffer, without specifying any size. In this case, the library will use the default
// buffer size of 4096 bytes.
+#include "test_macros.h"
+
+// MSVC warning C4242: '+=': conversion from 'const _Ty' to 'size_t', possible loss of data
+// MSVC warning C4244: 'argument': conversion from 'std::streamsize' to 'size_t', possible loss of data
+TEST_MSVC_DIAGNOSTIC_IGNORED(4242 4244)
+
#include <cassert>
#include <codecvt>
#include <fstream>
@@ -40,7 +46,6 @@
#include "../types.h"
#include "assert_macros.h"
#include "platform_support.h"
-#include "test_macros.h"
template <class BufferPolicy>
void test_read(BufferPolicy policy, const std::vector<std::streamsize>& payload_sizes) {
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.members/buffered_writes.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.members/buffered_writes.pass.cpp
index b5bbb0ca2ee4e7..545b238d23cb25 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.members/buffered_writes.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.members/buffered_writes.pass.cpp
@@ -29,6 +29,12 @@
// - Let the library manage a buffer, without specifying any size. In this case, the library will use the default
// buffer size of 4096 bytes.
+#include "test_macros.h"
+
+// MSVC warning C4242: '+=': conversion from 'const _Ty' to 'size_t', possible loss of data
+// MSVC warning C4244: 'argument': conversion from 'std::streamsize' to 'size_t', possible loss of data
+TEST_MSVC_DIAGNOSTIC_IGNORED(4242 4244)
+
#include <cassert>
#include <codecvt>
#include <fstream>
@@ -40,7 +46,6 @@
#include "../types.h"
#include "assert_macros.h"
#include "platform_support.h"
-#include "test_macros.h"
template <class BufferPolicy>
void test_write(BufferPolicy policy, const std::vector<std::streamsize>& payload_sizes) {
diff --git a/libcxx/test/std/language.support/support.runtime/csetjmp.pass.cpp b/libcxx/test/std/language.support/support.runtime/csetjmp.pass.cpp
index d6d32c371b9e5c..96a3be753ad988 100644
--- a/libcxx/test/std/language.support/support.runtime/csetjmp.pass.cpp
+++ b/libcxx/test/std/language.support/support.runtime/csetjmp.pass.cpp
@@ -8,6 +8,11 @@
// test <csetjmp>
+#include "test_macros.h"
+
+// MSVC warning C4611: interaction between '_setjmp' and C++ object destruction is non-portable
+TEST_MSVC_DIAGNOSTIC_IGNORED(4611)
+
#include <csetjmp>
#include <cassert>
#include <type_traits>
diff --git a/libcxx/test/std/ranges/range.adaptors/range.lazy.split/constraints.compile.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.lazy.split/constraints.compile.pass.cpp
index a942f439040929..86c6a96bdb6d6e 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.lazy.split/constraints.compile.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.lazy.split/constraints.compile.pass.cpp
@@ -14,6 +14,12 @@
// (forward_range<V> || tiny-range<Pattern>)
// class lazy_split_view;
+#include "test_macros.h"
+
+// This is a compile-only test, so "inline function is not defined" warnings are irrelevant.
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wundefined-inline")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Wundefined-inline")
+
#include <functional>
#include <ranges>
diff --git a/libcxx/test/std/ranges/range.utility/range.utility.conv/to.pass.cpp b/libcxx/test/std/ranges/range.utility/range.utility.conv/to.pass.cpp
index 03270f25fd92b2..5340ace0261eb7 100644
--- a/libcxx/test/std/ranges/range.utility/range.utility.conv/to.pass.cpp
+++ b/libcxx/test/std/ranges/range.utility/range.utility.conv/to.pass.cpp
@@ -11,6 +11,11 @@
// template<class C, input_range R, class... Args> requires (!view<C>)
// constexpr C to(R&& r, Args&&... args); // Since C++23
+#include "test_macros.h"
+
+// MSVC warning C4244: 'argument': conversion from '_Ty' to 'int', possible loss of data
+TEST_MSVC_DIAGNOSTIC_IGNORED(4244)
+
#include <ranges>
#include <algorithm>
@@ -19,7 +24,6 @@
#include <vector>
#include "container.h"
#include "test_iterators.h"
-#include "test_macros.h"
#include "test_range.h"
template <class Container, class Range, class... Args>
diff --git a/libcxx/test/std/strings/basic.string/string.cons/from_range_deduction.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/from_range_deduction.pass.cpp
index b2dab03506f03a..e264e642548233 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/from_range_deduction.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/from_range_deduction.pass.cpp
@@ -9,8 +9,6 @@
// <string>
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
-// To silence a GCC warning-turned-error re. `BadAlloc::value_type`.
-// ADDITIONAL_COMPILE_FLAGS: -Wno-unused-local-typedefs
// template<ranges::input_range R,
// class Allocator = allocator<ranges::range_value_t<R>>>
@@ -21,6 +19,12 @@
// The deduction guide shall not participate in overload resolution if Allocator
// is a type that does not qualify as an allocator (in addition to the `input_range` concept being satisfied by `R`).
+#include "test_macros.h"
+
+// To silence a GCC warning-turned-error re. `BadAlloc::value_type`.
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wunused-local-typedefs")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Wunused-local-typedefs")
+
#include <array>
#include <string>
diff --git a/libcxx/test/std/thread/thread.condition/notify_all_at_thread_exit_lwg3343.pass.cpp b/libcxx/test/std/thread/thread.condition/notify_all_at_thread_exit_lwg3343.pass.cpp
index ffb632a5149b5e..9e2e47234e0f3a 100644
--- a/libcxx/test/std/thread/thread.condition/notify_all_at_thread_exit_lwg3343.pass.cpp
+++ b/libcxx/test/std/thread/thread.condition/notify_all_at_thread_exit_lwg3343.pass.cpp
@@ -23,9 +23,13 @@
//
// void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk);
-#include "make_test_thread.h"
#include "test_macros.h"
+// MSVC warning C4583: 'X::cv_': destructor is not implicitly called
+TEST_MSVC_DIAGNOSTIC_IGNORED(4583)
+
+#include "make_test_thread.h"
+
#include <condition_variable>
#include <cassert>
#include <chrono>
diff --git a/libcxx/test/std/thread/thread.jthread/assign.move.pass.cpp b/libcxx/test/std/thread/thread.jthread/assign.move.pass.cpp
index 89521ad7660a12..a3af95f4b6f752 100644
--- a/libcxx/test/std/thread/thread.jthread/assign.move.pass.cpp
+++ b/libcxx/test/std/thread/thread.jthread/assign.move.pass.cpp
@@ -10,10 +10,14 @@
// UNSUPPORTED: libcpp-has-no-experimental-stop_token
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: availability-synchronization_library-missing
-// ADDITIONAL_COMPILE_FLAGS: -Wno-self-move
// jthread& operator=(jthread&&) noexcept;
+#include "test_macros.h"
+
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wself-move")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Wself-move")
+
#include <atomic>
#include <cassert>
#include <concepts>
@@ -24,7 +28,6 @@
#include <vector>
#include "make_test_thread.h"
-#include "test_macros.h"
static_assert(std::is_nothrow_move_assignable_v<std::jthread>);
diff --git a/libcxx/test/std/utilities/meta/meta.unary/dependent_return_type.compile.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/dependent_return_type.compile.pass.cpp
index b382940423e056..0d2269e3a1869d 100644
--- a/libcxx/test/std/utilities/meta/meta.unary/dependent_return_type.compile.pass.cpp
+++ b/libcxx/test/std/utilities/meta/meta.unary/dependent_return_type.compile.pass.cpp
@@ -10,14 +10,17 @@
// UNSUPPORTED: c++03, c++11
+#include "test_macros.h"
+
// ignore deprecated volatile return types
-// ADDITIONAL_COMPILE_FLAGS: -Wno-deprecated-volatile
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-volatile")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Wvolatile")
+// MSVC warning C5216: 'volatile int' a volatile qualified return type is deprecated in C++20
+TEST_MSVC_DIAGNOSTIC_IGNORED(5216)
#include <type_traits>
#include <utility>
-#include "test_macros.h"
-
template <class T>
std::add_const_t<T> add_const() {
return {};
diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move.pass.cpp
index 80d75e721e52e5..2efd30ff096c9d 100644
--- a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move.pass.cpp
+++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move.pass.cpp
@@ -8,9 +8,6 @@
// UNSUPPORTED: c++03
-// Self assignment post-conditions are tested.
-// ADDITIONAL_COMPILE_FLAGS: -Wno-self-move
-
// <memory>
// unique_ptr
@@ -20,11 +17,16 @@
// test move assignment. Should only require a MoveConstructible deleter, or if
// deleter is a reference, not even that.
+#include "test_macros.h"
+
+// Self assignment post-conditions are tested.
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wself-move")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Wself-move")
+
#include <memory>
#include <utility>
#include <cassert>
-#include "test_macros.h"
#include "deleter_types.h"
#include "unique_ptr_test_helper.h"
diff --git a/libcxx/test/std/utilities/variant/variant.variant/implicit_ctad.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/implicit_ctad.pass.cpp
index 514c1f87faad06..50861554470867 100644
--- a/libcxx/test/std/utilities/variant/variant.variant/implicit_ctad.pass.cpp
+++ b/libcxx/test/std/utilities/variant/variant.variant/implicit_ctad.pass.cpp
@@ -14,15 +14,16 @@
// Make sure that the implicitly-generated CTAD works.
+#include "test_macros.h"
+
// We make sure that it is not ill-formed, however we still produce a warning for
// this one because explicit construction from a variant using CTAD is ambiguous
-// (in the sense that the programer intent is not clear).
-// ADDITIONAL_COMPILE_FLAGS: -Wno-ctad-maybe-unsupported
+// (in the sense that the programmer intent is not clear).
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wctad-maybe-unsupported")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Wctad-maybe-unsupported")
#include <variant>
-#include "test_macros.h"
-
int main(int, char**) {
// This is the motivating example from P0739R0
{
>From 644380be1f2d949b693851394362eb65bb4d6082 Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Mon, 11 Dec 2023 18:49:09 -0800
Subject: [PATCH 5/6] Locally suppress some warnings.
---
.../alg.nonmodifying/alg.equal/equal.pass.cpp | 9 +++++++--
.../atomics.types.generic/general.compile.pass.cpp | 12 +++++++-----
.../atomics.types.generic/pointer.compile.pass.cpp | 14 +++++++++-----
.../notify_all_at_thread_exit_lwg3343.pass.cpp | 12 +++++++-----
4 files changed, 30 insertions(+), 17 deletions(-)
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 096bea7b74d242..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
@@ -25,9 +25,8 @@ 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 C4310: cast truncates constant value
// MSVC warning C4389: '==': signed/unsigned mismatch
-TEST_MSVC_DIAGNOSTIC_IGNORED(4242 4244 4310 4389)
+TEST_MSVC_DIAGNOSTIC_IGNORED(4242 4244 4389)
#include <algorithm>
#include <cassert>
@@ -65,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),
@@ -78,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/atomics/atomics.types.generic/general.compile.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/general.compile.pass.cpp
index f19d5de6ce3335..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
@@ -56,15 +56,11 @@
// void notify_all() noexcept;
// };
-#include "test_macros.h"
-
-// MSVC warning C4197: 'volatile std::atomic<operator_hijacker>': top-level volatile in cast is ignored
-TEST_MSVC_DIAGNOSTIC_IGNORED(4197)
-
#include <atomic>
#include <type_traits>
#include "operator_hijacker.h"
+#include "test_macros.h"
template <class T>
void test() {
@@ -78,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 26cfe1989f014e..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
@@ -78,15 +78,11 @@
// void notify_all() noexcept;
// };
-#include "test_macros.h"
-
-// MSVC warning C4197: 'volatile std::atomic<operator_hijacker *>': top-level volatile in cast is ignored
-TEST_MSVC_DIAGNOSTIC_IGNORED(4197)
-
#include <atomic>
#include <type_traits>
#include "operator_hijacker.h"
+#include "test_macros.h"
template <class T>
void test() {
@@ -102,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/thread/thread.condition/notify_all_at_thread_exit_lwg3343.pass.cpp b/libcxx/test/std/thread/thread.condition/notify_all_at_thread_exit_lwg3343.pass.cpp
index 9e2e47234e0f3a..4c8ba829ce685d 100644
--- a/libcxx/test/std/thread/thread.condition/notify_all_at_thread_exit_lwg3343.pass.cpp
+++ b/libcxx/test/std/thread/thread.condition/notify_all_at_thread_exit_lwg3343.pass.cpp
@@ -23,12 +23,8 @@
//
// void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk);
-#include "test_macros.h"
-
-// MSVC warning C4583: 'X::cv_': destructor is not implicitly called
-TEST_MSVC_DIAGNOSTIC_IGNORED(4583)
-
#include "make_test_thread.h"
+#include "test_macros.h"
#include <condition_variable>
#include <cassert>
@@ -39,6 +35,10 @@ TEST_MSVC_DIAGNOSTIC_IGNORED(4583)
int condition_variable_lock_skipped_counter = 0;
+TEST_DIAGNOSTIC_PUSH
+// MSVC warning C4583: 'X::cv_': destructor is not implicitly called
+TEST_MSVC_DIAGNOSTIC_IGNORED(4583)
+
union X {
X() : cv_() {}
~X() {}
@@ -46,6 +46,8 @@ union X {
unsigned char bytes_[sizeof(std::condition_variable)];
};
+TEST_DIAGNOSTIC_POP
+
void test()
{
constexpr int N = 3;
>From 0e28a3dd12f8a04fe5432877e6029daf179f358a Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Mon, 11 Dec 2023 19:46:15 -0800
Subject: [PATCH 6/6] Apply clang-format from CI.
---
.../algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
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 1f9cb9b9cee5a7..ec713196277d2d 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
@@ -64,9 +64,9 @@ 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)
+ TEST_DIAGNOSTIC_PUSH
+ // MSVC warning C4310: cast truncates constant value
+ TEST_MSVC_DIAGNOSTIC_IGNORED(4310)
UnderlyingType a[] = {
UnderlyingType(0x1000),
@@ -81,7 +81,7 @@ struct TestNarrowingEqualTo {
UnderlyingType(0x1603),
UnderlyingType(0x1604)};
- TEST_DIAGNOSTIC_POP
+ TEST_DIAGNOSTIC_POP
assert(std::equal(a, a + 5, b, std::equal_to<char>()));
#if TEST_STD_VER >= 14
More information about the libcxx-commits
mailing list