[libcxx-commits] [libcxx] [libc++][test] Enhance `ADDITIONAL_COMPILE_FLAGS`, use `TEST_MEOW_DIAGNOSTIC_IGNORED` sparingly (PR #75317)
Stephan T. Lavavej via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Dec 13 03:04:50 PST 2023
https://github.com/StephanTLavavej created https://github.com/llvm/llvm-project/pull/75317
This is the last PR that's needed (for now) to get libc++'s tests working with MSVC's STL.
It returns to the overall approach of #74974 by enhancing `ADDITIONAL_COMPILE_FLAGS` with `gcc-style-warnings` and `cl-style-warnings` features (because `-Wno-meow` and `/wdNNNN` are mutually unintelligible), addressing @philnik777's objection in https://github.com/llvm/llvm-project/pull/75133#pullrequestreview-1778075863 by keeping #75133's approach of introducing `TEST_MEOW_DIAGNOSTIC_IGNORED` only for local suppressions. The result is a minimal change from the status quo (it doesn't change any files away from using `ADDITIONAL_COMPILE_FLAGS` for whole-test suppressions) and should hopefully be acceptable to all maintainers.
I thought it was simplest to open a fresh PR with the following well-structured commits:
* features.py: Add `gcc-style-warnings` and `cl-style-warnings`.
+ Also refactor `_isClang` and `_isGCC`.
* Update `ADDITIONAL_COMPILE_FLAGS`, using `gcc-style-warnings` and `cl-style-warnings`.
* advance.pass.cpp: Remember to use `gcc-style-warnings`.
* implicit_ctad.pass.cpp: Fix comment typo.
* equal.pass.cpp: Use `gcc-style-warnings` and `cl-style-warnings`, locally suppress MSVC warning C4310.
* Locally suppress MSVC warnings C4197 and C4583.
* result_of11.pass.cpp: Overhaul how we suppress "deprecated volatile" warnings.
+ This avoids using the internal macros `_LIBCPP_SUPPRESS_DEPRECATED_PUSH`/`_LIBCPP_SUPPRESS_DEPRECATED_POP`.
+ This test was previously using `#pragma GCC diagnostic ignored "-Wvolatile"` for a whole-test suppression, but that doesn't need to apply to product code headers, so there wasn't a weird dance of having to include `"test_macros.h"` at the very top. I've chosen a minimal change of converting this to `TEST_MEOW_DIAGNOSTIC_IGNORED` in-place. If desired, I could attempt to replace this with `ADDITIONAL_COMPILE_FLAGS` for consistency with other whole-test suppresions.
* msvc_stdlib_force_include.h: No longer needs to simulate `_LIBCPP_SUPPRESS_DEPRECATED_PUSH`/`_LIBCPP_SUPPRESS_DEPRECATED_POP`.
>From 3314878a94c0ef88add9f914512aa1cf87790ee6 Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Tue, 12 Dec 2023 17:27:00 -0800
Subject: [PATCH 1/8] features.py: Add `gcc-style-warnings` and
`cl-style-warnings`.
Also refactor `_isClang` and `_isGCC`.
---
libcxx/utils/libcxx/test/features.py | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index 5e854917e6ef45..461e134f165fc8 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -13,9 +13,13 @@
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)
+_isAnyClangOrGCC = lambda cfg: _isAnyClang(cfg) or _isAnyGCC(cfg)
+_isClExe = lambda cfg: not _isAnyClangOrGCC(cfg)
_isMSVC = lambda cfg: "_MSC_VER" in compilerMacros(cfg)
_msvcVersion = lambda cfg: (int(compilerMacros(cfg)["_MSC_VER"]) // 100, int(compilerMacros(cfg)["_MSC_VER"]) % 100)
@@ -61,6 +65,9 @@ def _getAndroidDeviceApi(cfg):
# Lit features are evaluated in order. Some checks may require the compiler detection to have
# run first in order to work properly.
DEFAULT_FEATURES = [
+ # gcc-style-warnings detects compilers that understand -Wno-meow flags, unlike MSVC's compiler driver cl.exe.
+ Feature(name="gcc-style-warnings", when=_isAnyClangOrGCC),
+ Feature(name="cl-style-warnings", when=_isClExe),
Feature(name="apple-clang", when=_isAppleClang),
Feature(
name=lambda cfg: "apple-clang-{__clang_major__}".format(**compilerMacros(cfg)),
>From bbe8d6466a1107768fb962b9992f6fb67b8c5b59 Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Tue, 12 Dec 2023 17:26:50 -0800
Subject: [PATCH 2/8] Update ADDITIONAL_COMPILE_FLAGS, using
`gcc-style-warnings` and `cl-style-warnings`.
---
.../alg.replace/ranges.replace.pass.cpp | 3 +++
.../std/algorithms/alg.nonmodifying/alg.find/find.pass.cpp | 4 +++-
.../alg.nonmodifying/alg.find/ranges.find.pass.cpp | 5 ++++-
.../default_initializable.compile.pass.cpp | 2 +-
.../associative/map/map.modifiers/insert_range.pass.cpp | 2 +-
.../multimap/multimap.modifiers/insert_range.pass.cpp | 2 +-
.../containers/associative/multiset/insert_range.pass.cpp | 2 +-
.../std/containers/associative/set/insert_range.pass.cpp | 2 +-
.../containers/sequences/array/array.tuple/get.verify.cpp | 2 +-
.../unord.map/unord.map.modifiers/insert_range.pass.cpp | 2 +-
.../unord.multimap.modifiers/insert_range.pass.cpp | 2 +-
.../containers/unord/unord.multiset/insert_range.pass.cpp | 2 +-
.../std/containers/unord/unord.set/insert_range.pass.cpp | 2 +-
.../containers/views/mdspan/layout_stride/deduction.pass.cpp | 2 +-
.../std/containers/views/mdspan/mdspan/conversion.pass.cpp | 3 +++
.../test/std/depr/depr.c.headers/setjmp_h.compile.pass.cpp | 3 +++
.../depr.numeric.limits.has.denorm/deprecated.verify.cpp | 2 +-
.../fstreams/ifstream.members/buffered_reads.pass.cpp | 3 +++
.../fstreams/ofstream.members/buffered_writes.pass.cpp | 3 +++
.../std/language.support/support.runtime/csetjmp.pass.cpp | 3 +++
.../range.lazy.split/constraints.compile.pass.cpp | 3 +++
.../std/ranges/range.utility/range.utility.conv/to.pass.cpp | 3 +++
.../basic.string/string.cons/from_range_deduction.pass.cpp | 2 +-
libcxx/test/std/thread/thread.jthread/assign.move.pass.cpp | 2 +-
.../meta/meta.unary/dependent_return_type.compile.pass.cpp | 4 +++-
.../unique.ptr.class/unique.ptr.asgn/move.pass.cpp | 2 +-
.../utilities/variant/variant.variant/implicit_ctad.pass.cpp | 2 +-
27 files changed, 50 insertions(+), 19 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..16834782914b59 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
@@ -6,6 +6,9 @@
//
//===----------------------------------------------------------------------===//
+// MSVC warning C4244: 'argument': conversion from 'const _Ty2' to 'T', possible loss of data
+// ADDITIONAL_COMPILE_FLAGS(cl-style-warnings): /wd4244
+
// <algorithm>
// UNSUPPORTED: c++03, c++11, c++14, c++17
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..3141f1431fcc15 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,7 +6,9 @@
//
//===----------------------------------------------------------------------===//
-// ADDITIONAL_COMPILE_FLAGS: -Wno-sign-compare
+// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-sign-compare
+// MSVC warning C4389: '==': signed/unsigned mismatch
+// ADDITIONAL_COMPILE_FLAGS(cl-style-warnings): /wd4389
// <algorithm>
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..dbb58749a567e7 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,7 +10,10 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17
-// ADDITIONAL_COMPILE_FLAGS: -Wno-sign-compare
+// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-sign-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
+// ADDITIONAL_COMPILE_FLAGS(cl-style-warnings): /wd4242 /wd4244
// 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*>
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..ee77b1ac3c48b3 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
@@ -10,7 +10,7 @@
// 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
+// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-ignored-qualifiers
// template<class T>
// concept default_initializable = constructible_from<T> &&
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..0d4b1c960a958e 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
@@ -8,7 +8,7 @@
// 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
+// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-missing-field-initializers
// <map>
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..a804cbf0cf2066 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
@@ -8,7 +8,7 @@
// 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
+// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-missing-field-initializers
// <map>
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..d57e14f4b59c85 100644
--- a/libcxx/test/std/containers/associative/multiset/insert_range.pass.cpp
+++ b/libcxx/test/std/containers/associative/multiset/insert_range.pass.cpp
@@ -8,7 +8,7 @@
// 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
+// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-missing-field-initializers
// <set>
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..e6c54d84d6e403 100644
--- a/libcxx/test/std/containers/associative/set/insert_range.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/insert_range.pass.cpp
@@ -8,7 +8,7 @@
// 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
+// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-missing-field-initializers
// <set>
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..d776d72b054670 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
@@ -11,7 +11,7 @@
// template <size_t I, class T, size_t N> T& get(array<T, N>& a);
// Prevent -Warray-bounds from issuing a diagnostic when testing with clang verify.
-// ADDITIONAL_COMPILE_FLAGS: -Wno-array-bounds
+// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-array-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..d1c90c4ed48539 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
@@ -8,7 +8,7 @@
// 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
+// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-missing-field-initializers
// <unordered_map>
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..e6924ad52f6a79 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
@@ -8,7 +8,7 @@
// 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
+// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-missing-field-initializers
// <unordered_map>
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..c2d5ed3278332e 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
@@ -8,7 +8,7 @@
// 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
+// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-missing-field-initializers
// <set>
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..0fac2211af2ebe 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
@@ -8,7 +8,7 @@
// 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
+// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-missing-field-initializers
// <set>
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..259f61536ee375 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,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
-// ADDITIONAL_COMPILE_FLAGS: -Wno-ctad-maybe-unsupported
+// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-ctad-maybe-unsupported
// <mdspan>
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..db22e148b34c56 100644
--- a/libcxx/test/std/containers/views/mdspan/mdspan/conversion.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/mdspan/conversion.pass.cpp
@@ -7,6 +7,9 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// MSVC warning C4244: 'initializing': conversion from '_Ty' to '_Ty', possible loss of data
+// ADDITIONAL_COMPILE_FLAGS(cl-style-warnings): /wd4244
+
// <mdspan>
// template<class OtherElementType, class OtherExtents,
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..f14173a7531663 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
@@ -6,6 +6,9 @@
//
//===----------------------------------------------------------------------===//
+// MSVC warning C4611: interaction between '_setjmp' and C++ object destruction is non-portable
+// ADDITIONAL_COMPILE_FLAGS(cl-style-warnings): /wd4611
+
// test <setjmp.h>
//
// Even though <setjmp.h> is not provided by libc++, we still test that
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..eb8611a85efba4 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,7 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
-// ADDITIONAL_COMPILE_FLAGS: -Wno-unused-value
+// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-unused-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..1fd940f69d7ecc 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
@@ -7,6 +7,9 @@
//===----------------------------------------------------------------------===//
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT
+// 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
+// ADDITIONAL_COMPILE_FLAGS(cl-style-warnings): /wd4242 /wd4244
// UNSUPPORTED: c++03
// <fstream>
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..d56bb308e43c5b 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
@@ -7,6 +7,9 @@
//===----------------------------------------------------------------------===//
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT
+// 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
+// ADDITIONAL_COMPILE_FLAGS(cl-style-warnings): /wd4242 /wd4244
// UNSUPPORTED: c++03
// <fstream>
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..5e23a4a21eb791 100644
--- a/libcxx/test/std/language.support/support.runtime/csetjmp.pass.cpp
+++ b/libcxx/test/std/language.support/support.runtime/csetjmp.pass.cpp
@@ -6,6 +6,9 @@
//
//===----------------------------------------------------------------------===//
+// MSVC warning C4611: interaction between '_setjmp' and C++ object destruction is non-portable
+// ADDITIONAL_COMPILE_FLAGS(cl-style-warnings): /wd4611
+
// test <csetjmp>
#include <csetjmp>
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..9734ed495f334c 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
@@ -8,6 +8,9 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17
+// This is a compile-only test, so "inline function is not defined" warnings are irrelevant.
+// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-undefined-inline
+
// template<input_range V, forward_range Pattern>
// requires view<V> && view<Pattern> &&
// indirectly_comparable<iterator_t<V>, iterator_t<Pattern>, ranges::equal_to> &&
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..3df88d6a2dcc38 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
@@ -6,6 +6,9 @@
//
//===----------------------------------------------------------------------===//
+// MSVC warning C4244: 'argument': conversion from '_Ty' to 'int', possible loss of data
+// ADDITIONAL_COMPILE_FLAGS(cl-style-warnings): /wd4244
+
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// template<class C, input_range R, class... Args> requires (!view<C>)
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 83c3dfdfa79dde..44aa0980972bd1 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
@@ -10,7 +10,7 @@
// 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
+// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-unused-local-typedefs
// template<ranges::input_range R,
// class Allocator = allocator<ranges::range_value_t<R>>>
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..d7e50fedd468f2 100644
--- a/libcxx/test/std/thread/thread.jthread/assign.move.pass.cpp
+++ b/libcxx/test/std/thread/thread.jthread/assign.move.pass.cpp
@@ -10,7 +10,7 @@
// 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
+// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-self-move
// jthread& operator=(jthread&&) noexcept;
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..935a6e3db0017e 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
@@ -11,7 +11,9 @@
// UNSUPPORTED: c++03, c++11
// ignore deprecated volatile return types
-// ADDITIONAL_COMPILE_FLAGS: -Wno-deprecated-volatile
+// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-deprecated-volatile
+// MSVC warning C5216: 'volatile int' a volatile qualified return type is deprecated in C++20
+// ADDITIONAL_COMPILE_FLAGS(cl-style-warnings): /wd5216
#include <type_traits>
#include <utility>
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..1b1f848e4d5877 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
@@ -9,7 +9,7 @@
// UNSUPPORTED: c++03
// Self assignment post-conditions are tested.
-// ADDITIONAL_COMPILE_FLAGS: -Wno-self-move
+// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-self-move
// <memory>
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..80b38f986d0b6d 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
@@ -17,7 +17,7 @@
// 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
+// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-ctad-maybe-unsupported
#include <variant>
>From e161cdc5919dfc90e910a37fe3cf437bd8a3ced1 Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Tue, 12 Dec 2023 17:26:57 -0800
Subject: [PATCH 3/8] advance.pass.cpp: Remember to use `gcc-style-warnings`.
---
.../iterator.primitives/iterator.operations/advance.pass.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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..ba94cf67a65383 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
@@ -27,7 +27,7 @@
// <TODO:Remove brackets> below
// Make sure we catch forced conversions to the difference_type if they happen.
-// ADDITIONAL_COMPILE_FLAGS<TODO:Remove brackets>: -Wsign-conversion
+// ADDITIONAL_COMPILE_FLAGS<TODO:Remove brackets>(gcc-style-warnings): -Wsign-conversion
#include <iterator>
#include <cassert>
>From 5215a4782cc7133e910344eb22eed9d2ab0db252 Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Tue, 12 Dec 2023 18:15:12 -0800
Subject: [PATCH 4/8] implicit_ctad.pass.cpp: Fix comment typo.
---
.../utilities/variant/variant.variant/implicit_ctad.pass.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 80b38f986d0b6d..8e0432834e19a6 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
@@ -16,7 +16,7 @@
// 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).
+// (in the sense that the programmer intent is not clear).
// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-ctad-maybe-unsupported
#include <variant>
>From f736181a798b806f9317475918c8a1688b919ae4 Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Tue, 12 Dec 2023 17:57:53 -0800
Subject: [PATCH 5/8] equal.pass.cpp: Use `gcc-style-warnings` and
`cl-style-warnings`, locally suppress MSVC warning C4310.
---
.../alg.nonmodifying/alg.equal/equal.pass.cpp | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
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..c3ba3f89b4de3c 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
@@ -19,7 +19,11 @@
// equal(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
// We test the cartesian product, so we sometimes compare differently signed types
-// ADDITIONAL_COMPILE_FLAGS: -Wno-sign-compare
+// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-sign-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
+// ADDITIONAL_COMPILE_FLAGS(cl-style-warnings): /wd4242 /wd4244 /wd4389
#include <algorithm>
#include <cassert>
@@ -58,6 +62,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 +79,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>()));
>From ab3f269a3eee0b67a252ab67c1daac0a03ab970f Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Tue, 12 Dec 2023 17:25:20 -0800
Subject: [PATCH 6/8] Locally suppress MSVC warnings C4197 and C4583.
---
.../atomics.types.generic/general.compile.pass.cpp | 6 ++++++
.../atomics.types.generic/pointer.compile.pass.cpp | 8 ++++++++
.../notify_all_at_thread_exit_lwg3343.pass.cpp | 6 ++++++
3 files changed, 20 insertions(+)
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/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..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
@@ -35,6 +35,10 @@
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() {}
@@ -42,6 +46,8 @@ union X {
unsigned char bytes_[sizeof(std::condition_variable)];
};
+TEST_DIAGNOSTIC_POP
+
void test()
{
constexpr int N = 3;
>From 64c2732df7ffd1f33ab3f0939df0510e9b1154c8 Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Tue, 12 Dec 2023 17:25:28 -0800
Subject: [PATCH 7/8] result_of11.pass.cpp: Overhaul how we suppress
"deprecated volatile" warnings.
This avoids using the internal macros `_LIBCPP_SUPPRESS_DEPRECATED_PUSH`/`_LIBCPP_SUPPRESS_DEPRECATED_POP`.
---
.../meta.trans/meta.trans.other/result_of11.pass.cpp | 12 ++++--------
1 file changed, 4 insertions(+), 8 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
>From e4d726565b8aff5a4bf383bb5ddec9285a9aa930 Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Tue, 12 Dec 2023 17:25:29 -0800
Subject: [PATCH 8/8] msvc_stdlib_force_include.h: No longer needs to simulate
`_LIBCPP_SUPPRESS_DEPRECATED_PUSH`/`_LIBCPP_SUPPRESS_DEPRECATED_POP`.
---
libcxx/test/support/msvc_stdlib_force_include.h | 10 ----------
1 file changed, 10 deletions(-)
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
More information about the libcxx-commits
mailing list