From 2e19827ee060c820f10bd50162ca9a2b443401e8 Mon Sep 17 00:00:00 2001 From: YexuanXiao Date: Sat, 26 Jul 2025 17:03:21 +0800 Subject: [PATCH 1/3] Guard headers and suppress Clang warnings --- .../tests/Dev11_0000000_null_forward_iterators/test.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/std/tests/Dev11_0000000_null_forward_iterators/test.cpp b/tests/std/tests/Dev11_0000000_null_forward_iterators/test.cpp index 94008bd066a..3da7864c61d 100644 --- a/tests/std/tests/Dev11_0000000_null_forward_iterators/test.cpp +++ b/tests/std/tests/Dev11_0000000_null_forward_iterators/test.cpp @@ -10,7 +10,9 @@ #include #include #include +#if _HAS_CXX17 #include +#endif // _HAS_CXX17 #include #include #include @@ -18,13 +20,19 @@ #include #include #include +#if _HAS_CXX20 #include +#endif // _HAS_CXX20 #include #include #include #include #include +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wnontrivial-memcall" +#endif // __clang__ + using namespace std; // N3797 24.2.5 [forward.iterators]/2: From 79a6b3842ee747f6b5547fdf642a05f80b7add85 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Sat, 2 Aug 2025 02:30:37 -0700 Subject: [PATCH 2/3] Gather 17/20 headers at the end, add missing ``. --- .../Dev11_0000000_null_forward_iterators/test.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/std/tests/Dev11_0000000_null_forward_iterators/test.cpp b/tests/std/tests/Dev11_0000000_null_forward_iterators/test.cpp index 3da7864c61d..a0adcc533f2 100644 --- a/tests/std/tests/Dev11_0000000_null_forward_iterators/test.cpp +++ b/tests/std/tests/Dev11_0000000_null_forward_iterators/test.cpp @@ -10,9 +10,6 @@ #include #include #include -#if _HAS_CXX17 -#include -#endif // _HAS_CXX17 #include #include #include @@ -20,15 +17,21 @@ #include #include #include -#if _HAS_CXX20 -#include -#endif // _HAS_CXX20 #include #include #include #include #include +#if _HAS_CXX17 +#include +#include +#endif // _HAS_CXX17 + +#if _HAS_CXX20 +#include +#endif // _HAS_CXX20 + #ifdef __clang__ #pragma clang diagnostic ignored "-Wnontrivial-memcall" #endif // __clang__ From af01c41cce1375485865d200de5c0473cef51a20 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Sat, 2 Aug 2025 02:35:53 -0700 Subject: [PATCH 3/3] Avoid aligned_union_t, avoid the warning. --- .../test.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/tests/std/tests/Dev11_0000000_null_forward_iterators/test.cpp b/tests/std/tests/Dev11_0000000_null_forward_iterators/test.cpp index a0adcc533f2..b548e3d443d 100644 --- a/tests/std/tests/Dev11_0000000_null_forward_iterators/test.cpp +++ b/tests/std/tests/Dev11_0000000_null_forward_iterators/test.cpp @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#define _SILENCE_CXX23_ALIGNED_UNION_DEPRECATION_WARNING #define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING #define _SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING @@ -32,10 +31,6 @@ #include #endif // _HAS_CXX20 -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wnontrivial-memcall" -#endif // __clang__ - using namespace std; // N3797 24.2.5 [forward.iterators]/2: @@ -102,14 +97,14 @@ void test_iterator() { } { - aligned_union_t<0, FwdIt> au3; - aligned_union_t<0, FwdIt> au4; + alignas(FwdIt) unsigned char buf3[sizeof(FwdIt)]; + alignas(FwdIt) unsigned char buf4[sizeof(FwdIt)]; - FwdIt* p3 = reinterpret_cast(&au3); - FwdIt* p4 = reinterpret_cast(&au4); + memset(buf3, 0xCC, sizeof(FwdIt)); + memset(buf4, 0xDD, sizeof(FwdIt)); - memset(p3, 0xCC, sizeof(FwdIt)); - memset(p4, 0xDD, sizeof(FwdIt)); + FwdIt* p3 = reinterpret_cast(buf3); + FwdIt* p4 = reinterpret_cast(buf4); new (p3) FwdIt{}; new (p4) FwdIt{};