From 26809380afa8fa0f3f26ed51ed3349ec5ce37257 Mon Sep 17 00:00:00 2001 From: Casey Carter Date: Thu, 15 Feb 2024 13:40:16 -0800 Subject: [PATCH 1/6] Add `-Wno-overriding-option` to Clang lines in `floating_point_model_matrix` LLVM-D158137 renamed the `overriding-t-option` warning to `overriding-option`. To support transitioning, let's try to disable both and tell the compiler to ignore unrecognized warning options. --- tests/std/tests/floating_point_model_matrix.lst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/std/tests/floating_point_model_matrix.lst b/tests/std/tests/floating_point_model_matrix.lst index 551ad81e92..cca86c70c4 100644 --- a/tests/std/tests/floating_point_model_matrix.lst +++ b/tests/std/tests/floating_point_model_matrix.lst @@ -29,6 +29,6 @@ ASAN PM_CL="/O2 /MD /permissive- -fsanitize=address /Zi" PM_LINK="/debug" PM_CL="/O2 /MT /GL" ASAN PM_CL="/O2 /MT /GL -fsanitize=address /Zi" PM_LINK="/debug" # TRANSITION, -Wno-unused-command-line-argument is needed for the internal test harness -PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-unused-command-line-argument -Wno-overriding-t-option /Od /MTd" -PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-unused-command-line-argument -Wno-overriding-t-option /O2 /MT" -PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-unused-command-line-argument -Wno-overriding-t-option /O2 /MD /Oi-" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-unused-command-line-argument -Wno-unknown-warning-option -Wno-overriding-t-option -Wno-overriding-option /Od /MTd" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-unused-command-line-argument -Wno-unknown-warning-option -Wno-overriding-t-option -Wno-overriding-option /O2 /MT" +PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing -Wno-unqualified-std-cast-call -Wno-unused-command-line-argument -Wno-unknown-warning-option -Wno-overriding-t-option -Wno-overriding-option /O2 /MD /Oi-" From 46dc4dbacb292f00df0d3420d2d5ad7a68865719 Mon Sep 17 00:00:00 2001 From: Casey Carter Date: Tue, 5 Mar 2024 09:37:32 -0800 Subject: [PATCH 2/6] Fix clang missing-field-initializer warnings Clang 18 has started diagnosing uses of designated initializers that omit initializers for members without default initializers. This change adds default initializers to types we control and avoids using designated initializers for types we do not. This only affects a couple of tests. --- tests/std/include/test_format_support.hpp | 2 +- .../test.cpp | 2 +- .../P0896R4_ranges_iterator_machinery/test.cpp | 18 +++++++++--------- .../tests/P2093R14_formatted_output/test.cpp | 17 ++++++++--------- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/tests/std/include/test_format_support.hpp b/tests/std/include/test_format_support.hpp index 60ee59410c..8c8b27d002 100644 --- a/tests/std/include/test_format_support.hpp +++ b/tests/std/include/test_format_support.hpp @@ -70,7 +70,7 @@ template struct testing_callbacks { std::_Fmt_align expected_alignment = std::_Fmt_align::_None; std::_Fmt_sign expected_sign = std::_Fmt_sign::_None; - std::basic_string_view expected_fill; + std::basic_string_view expected_fill{}; int expected_width = -1; std::size_t expected_dynamic_width = static_cast(-1); bool expected_auto_dynamic_width = false; diff --git a/tests/std/tests/P0355R7_calendars_and_time_zones_formatting/test.cpp b/tests/std/tests/P0355R7_calendars_and_time_zones_formatting/test.cpp index 6b441e01ab..86734f6e86 100644 --- a/tests/std/tests/P0355R7_calendars_and_time_zones_formatting/test.cpp +++ b/tests/std/tests/P0355R7_calendars_and_time_zones_formatting/test.cpp @@ -46,7 +46,7 @@ template template struct testing_callbacks { _Fmt_align expected_alignment = _Fmt_align::_None; - basic_string_view expected_fill; + basic_string_view expected_fill{}; int expected_width = -1; size_t expected_dynamic_width = static_cast(-1); bool expected_auto_dynamic_width = false; diff --git a/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp b/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp index f19b3abb29..70f50d2d7f 100644 --- a/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp +++ b/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp @@ -1943,15 +1943,15 @@ namespace iter_ops { std::random_access_iterator_tag; struct trace { - unsigned int compares_; - unsigned int differences_; - unsigned int increments_; - unsigned int decrements_; - unsigned int assignments_; - unsigned int seeks_; - unsigned int sizes_; - unsigned int begins_; - unsigned int ends_; + unsigned int compares_ = 0; + unsigned int differences_ = 0; + unsigned int increments_ = 0; + unsigned int decrements_ = 0; + unsigned int assignments_ = 0; + unsigned int seeks_ = 0; + unsigned int sizes_ = 0; + unsigned int begins_ = 0; + unsigned int ends_ = 0; bool operator==(trace const&) const = default; }; diff --git a/tests/std/tests/P2093R14_formatted_output/test.cpp b/tests/std/tests/P2093R14_formatted_output/test.cpp index 92eb088494..43e493c6f5 100644 --- a/tests/std/tests/P2093R14_formatted_output/test.cpp +++ b/tests/std/tests/P2093R14_formatted_output/test.cpp @@ -153,10 +153,10 @@ namespace test { public: // Construct a new semaphore in the parent process. win_semaphore() { - SECURITY_ATTRIBUTES semaphore_attributes{ - .nLength = sizeof(SECURITY_ATTRIBUTES), - .bInheritHandle = TRUE, // The child process will inherit this handle. - }; + SECURITY_ATTRIBUTES semaphore_attributes{}; + semaphore_attributes.nLength = sizeof(SECURITY_ATTRIBUTES); + semaphore_attributes.bInheritHandle = TRUE; // The child process will inherit this handle. + m_handle = CreateSemaphoreW(&semaphore_attributes, 0, 1, nullptr); assert(m_handle != nullptr); } @@ -648,11 +648,10 @@ int main(int argc, char* argv[]) { // The entire purpose of this code is to hide the child process's console window, // to avoid rapid flickering during test runs. - STARTUPINFOW startup_info{ - .cb = sizeof(STARTUPINFOW), - .dwFlags = STARTF_USESHOWWINDOW, - .wShowWindow = SW_HIDE, - }; + STARTUPINFOW startup_info{}; + startup_info.cb = sizeof(STARTUPINFOW); + startup_info.dwFlags = STARTF_USESHOWWINDOW; + startup_info.wShowWindow = SW_HIDE; constexpr BOOL inherit_handles = TRUE; From 51204d68b6177f42723b7290fbc4cbf63807e237 Mon Sep 17 00:00:00 2001 From: Casey Carter Date: Tue, 5 Mar 2024 09:45:23 -0800 Subject: [PATCH 3/6] Suppress clang warning in GH_000935_complex_numerical_accuracy Clang warns that "use of NaN is undefined behavior due to the currently enabled floating-point options" in some floating-point contract modes. --- tests/std/tests/GH_000935_complex_numerical_accuracy/test.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/std/tests/GH_000935_complex_numerical_accuracy/test.cpp b/tests/std/tests/GH_000935_complex_numerical_accuracy/test.cpp index 3f3fa66186..8b4ddaedc5 100644 --- a/tests/std/tests/GH_000935_complex_numerical_accuracy/test.cpp +++ b/tests/std/tests/GH_000935_complex_numerical_accuracy/test.cpp @@ -1,6 +1,10 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wnan-infinity-disabled" +#endif // __clang__ + #include #include #include From 8d15355056d83f54d5f2d50feab267de9b2fd6d4 Mon Sep 17 00:00:00 2001 From: Casey Carter Date: Tue, 5 Mar 2024 09:56:51 -0800 Subject: [PATCH 4/6] Don't test equal_to with different enumerations Clang 18 SFINAES away the return type in C++23. I've made this compiler-agnostic with the expectation that other compilers will follow suit. --- tests/std/tests/GH_000431_equal_family/test.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/std/tests/GH_000431_equal_family/test.cpp b/tests/std/tests/GH_000431_equal_family/test.cpp index 00c835d9ad..2c06728b66 100644 --- a/tests/std/tests/GH_000431_equal_family/test.cpp +++ b/tests/std/tests/GH_000431_equal_family/test.cpp @@ -244,7 +244,11 @@ void test_algorithms(EqualFn equal_fn) { assert(equal_fn(begin(arr2), end(arr2), begin(arr3), end(arr3), equal_to{})); assert(equal_fn(begin(arr2), end(arr2), begin(arr3), end(arr3), equal_to{})); +#if !_HAS_CXX23 + // The return type of equal_to::operator(T, U) SFINAES + // when T and U are different enumeration types. assert(equal_fn(begin(arr3), end(arr3), begin(arr4), end(arr4), equal_to<>{})); +#endif // !_HAS_CXX23 assert(equal_fn(begin(arr3), end(arr3), begin(arr4), end(arr4), equal_to{})); assert(equal_fn(begin(arr3), end(arr3), begin(arr4), end(arr4), equal_to{})); } From 20c391aefbaacb3f6eb7ca7411957311b66bf038 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 5 Mar 2024 10:30:29 -0800 Subject: [PATCH 5/6] Code review feedback. --- tests/std/tests/GH_000431_equal_family/test.cpp | 2 +- .../tests/P0355R7_calendars_and_time_zones_formatting/test.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/std/tests/GH_000431_equal_family/test.cpp b/tests/std/tests/GH_000431_equal_family/test.cpp index 2c06728b66..21a952bae2 100644 --- a/tests/std/tests/GH_000431_equal_family/test.cpp +++ b/tests/std/tests/GH_000431_equal_family/test.cpp @@ -245,7 +245,7 @@ void test_algorithms(EqualFn equal_fn) { assert(equal_fn(begin(arr2), end(arr2), begin(arr3), end(arr3), equal_to{})); #if !_HAS_CXX23 - // The return type of equal_to::operator(T, U) SFINAES + // The return type of equal_to::operator()(T, U) SFINAEs // when T and U are different enumeration types. assert(equal_fn(begin(arr3), end(arr3), begin(arr4), end(arr4), equal_to<>{})); #endif // !_HAS_CXX23 diff --git a/tests/std/tests/P0355R7_calendars_and_time_zones_formatting/test.cpp b/tests/std/tests/P0355R7_calendars_and_time_zones_formatting/test.cpp index 86734f6e86..478ce17c0b 100644 --- a/tests/std/tests/P0355R7_calendars_and_time_zones_formatting/test.cpp +++ b/tests/std/tests/P0355R7_calendars_and_time_zones_formatting/test.cpp @@ -54,7 +54,7 @@ struct testing_callbacks { size_t expected_dynamic_precision = static_cast(-1); bool expected_auto_dynamic_precision = false; bool expected_localized = false; - vector<_Chrono_spec>& expected_chrono_specs; + vector<_Chrono_spec>& expected_chrono_specs{}; size_t curr_index = 0; void _On_align(_Fmt_align aln) { From 57e74653b488fd1f2939e5f34e61cce2f0c211ff Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 5 Mar 2024 11:00:22 -0800 Subject: [PATCH 6/6] STL NEEDS CAFFEINE --- .../tests/P0355R7_calendars_and_time_zones_formatting/test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/std/tests/P0355R7_calendars_and_time_zones_formatting/test.cpp b/tests/std/tests/P0355R7_calendars_and_time_zones_formatting/test.cpp index 478ce17c0b..86734f6e86 100644 --- a/tests/std/tests/P0355R7_calendars_and_time_zones_formatting/test.cpp +++ b/tests/std/tests/P0355R7_calendars_and_time_zones_formatting/test.cpp @@ -54,7 +54,7 @@ struct testing_callbacks { size_t expected_dynamic_precision = static_cast(-1); bool expected_auto_dynamic_precision = false; bool expected_localized = false; - vector<_Chrono_spec>& expected_chrono_specs{}; + vector<_Chrono_spec>& expected_chrono_specs; size_t curr_index = 0; void _On_align(_Fmt_align aln) {